GithubHelp home page GithubHelp logo

prodis / miss-elixir Goto Github PK

View Code? Open in Web Editor NEW
42.0 2.0 4.0 383 KB

Some functions that I miss in Elixir standard library (and maybe you too).

License: Apache License 2.0

Elixir 94.66% Makefile 5.34%
elixir elixir-lang prodis

miss-elixir's Introduction

Miss Elixir

Some functions that I miss in Elixir standard library (and maybe you too).

Miss Elixir


Hex.pm Docs Build Status Coverage Status License

Miss Elixir library brings in a non-intrusive way some extra functions that, for different reasons, are not part of the Elixir standard library.

None of the functions in Miss Elixir has the same name of functions present in the correspondent Elixir module.

Read about the motivation to create this Elixir library in this blog post.

Installation

The package can be installed by adding miss to your list of dependencies in mix.exs:

def deps do
  [
    {:miss, "~> 0.1.5"}
  ]
end

Usage

The order of the Miss namespace preceding the existing Elixir modules to be extended was made by intention. For example, Miss.String.

The modules in Miss Elixir are not intended to be used with aliases. Always use the entire namespace to make explicit that module/function does not belong to Elixir standard library.

# Do not do that!
alias Miss.Kernel
Kernel.div_rem(10, 2)

# Instead, use like that:
Miss.Kernel.div_rem(10, 2)

Navigate in the documentation of each module to find out all the available functions and detailed examples.

Below there are some examples.

String

iex> Miss.String.build(["string", 123, true])
"string123true"

iex> Miss.String.build("What ", "do you", " miss?")
"What do you miss?"

Map

iex> Miss.Map.rename_key(%{a: 1, b: 2, c: 3}, :b, :bbb)
%{a: 1, bbb: 2, c: 3}

iex> defmodule Post do
...>   defstruct [:title, :text, :date, :author, comments: []]
...>  end
...>
...>  defmodule Author do
...>    defstruct [:id, :name]
...>  end
...>
...>  defmodule Comment do
...>    defstruct [:text]
...>  end
...>
...> post = %Post{
...>   title: "My post",
...>   text: "Something really interesting",
...>   date: ~D[2010-09-01],
...>   author: %Author{
...>     id: 1234,
...>     name: "Pedro Bonamides"
...>   },
...>   comments: [
...>     %Comment{text: "Comment one"},
...>     %Comment{text: "Comment two"}
...>   ]
...> }
...> Miss.Map.from_nested_struct(post, [{Date, :skip}])
%{
  title: "My post",
  text: "Something really interesting",
  date: ~D[2010-09-01],
  author: %{
    id: 1234,
    name: "Pedro Bonamides"
  },
  comments: [
    %{text: "Comment one"},
    %{text: "Comment two"}
  ]
}

Kernel

iex> Miss.Kernel.div_rem(45, 2)
{22, 1}

iex> defmodule User do
...>   defstruct name: "User"
...> end
...>
...> Miss.Kernel.struct_list(User, [%{name: "Akira"}, %{name: "Fernando"}])
[%User{name: "Akira"}, %User{name: "Fernando"}]

List

iex> Miss.List.intersection([1, 2, 3, 4, 5], [0, 2, 4, 6, 8])
[2, 4]

Full documentation

The full documentation is available at https://hexdocs.pm/miss.

Contributing

See the contributing guide.

License

Miss Elixir is released under the Apache 2.0 License. See the LICENSE file.

Copyright ยฉ 2020-2021 Fernando Hamasaki de Amorim

Author

Fernando Hamasaki de Amorim (prodis)

Prodis

miss-elixir's People

Contributors

kianmeng avatar prodis avatar zekus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

miss-elixir's Issues

What do you miss?

What do you miss in Elixir that is not part of the standard library?

This issue is an open space to suggest a new feature in Miss Elixir library.

For example:

  • A function that you would like to use in an existing Elixir module.
  • Some function/module that you created inside your own application for generic purposes.
  • An idea for a new module.
  • A suggestion you made to the Elixir standard library that was reject.

The idea here is not to compete with Elixir features, but to have an opportunity to bring ideas for reusable common functions that for different reasons are not part (yet) of the Elixir standard library.

Read about the motivation behind creating the Miss Elixir library in this blog post: https://fernandohamasaki.com/miss-elixir.

You can drop your ideas in the comments. For potential new functions/features, new issues would be created to be refined or discussed in more details.

๐Ÿ’œ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.