https://github.com/ruby2elixir/elixir_prelude
Small set of useful utility functions.
https://github.com/ruby2elixir/elixir_prelude
Last synced: 10 months ago
JSON representation
Small set of useful utility functions.
- Host: GitHub
- URL: https://github.com/ruby2elixir/elixir_prelude
- Owner: ruby2elixir
- License: wtfpl
- Created: 2016-03-07T15:13:25.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-14T11:22:02.000Z (over 9 years ago)
- Last Synced: 2025-03-28T02:05:29.153Z (10 months ago)
- Language: Elixir
- Homepage: https://hexdocs.pm/elixir_prelude/api-reference.html
- Size: 20.5 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Elixir Prelude
[](https://travis-ci.org/ruby2elixir/elixir_prelude)
[](https://hex.pm/packages/elixir_prelude)

Small set of useful utility functions.
Forked to release on Hex.pm, see: https://github.com/houshuang/elixir-prelude/issues/1
## Installation
1. Add `elixir_prelude` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:elixir_prelude, "~> 0.2"}]
end
```
## Usage
The most useful utility is provided by Prelude.Map to work with deeply nested Maps or Structs.
```elixir
defmodule Data do
defstruct data: %{}
end
Prelude.Map.deep_put(%Data{}, [:data, :b, :c, :d], 2)
#=> %Data{data: %{b: %{c: %{d: 2}}}}
Prelude.Map.deep_get(%Data{data: %{b: %{c: %{d: 2}}}}, [:data, :b, :c, :d])
#=> 2
Prelude.Map.del_in(%Data{data: %{b: %{c: %{d: 2}}}}, [:data, :b, :c, :d])
#=> %Data{data: %{b: %{c: %{}}}}
```
Other modules:
- Prelude.Atom
- Prelude.List
- Prelude.String
This package has a set of functions that I extracted from projects I worked on (mainly [this](https://github.com/houshuang/survey)). Some are very trivial, others (especially in the Prelude.Map module) are more involved. I am mainly putting it together for my own future reuse, but some of it might be useful to others. I would like to add tests, and I will keep adding functions as they come up. Pull requests or suggestions for new functions, better APIs etc are welcome (tests would be awesome).
Stian Håklev, shaklev@gmail.com, http://reganmian.net
See CHANGELOG.md for progress.