GithubHelp home page GithubHelp logo

tchigher / miss-elixir Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prodis/miss-elixir

0.0 0.0 0.0 80 KB

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

License: Apache License 2.0

Elixir 94.46% Makefile 5.54%

miss-elixir's Introduction

Miss Elixir

Some functions that I miss in Elixir core (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 core.

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.1"}
  ]
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 core.

# 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 Fernando Hamasaki de Amorim

Author

Fernando Hamasaki de Amorim (prodis)

Prodis

miss-elixir's People

Contributors

prodis avatar

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.