deep-merge.cr

  • deep-merge

Adds support for deep merges to =Hash=

#+BEGIN_SRC crystal

normal merge

{ "a" => { "b" => 4 } }.merge({ "a" => { "c" => true } }) => { "a" => { "c" => true } }

deep merge

{ "a" => { "b" => 4 } }.deep_merge({ "a" => { "c" => true } }) => { "a" => { "b" => 4, "c" => true } } #+END_SRC

  • Installation

Add it to =shards.yml= in your project:

#+BEGIN_SRC yaml dependencies: deep-merge: gitlab: peterhoeg/deep-merge.cr #+END_SRC

  • Usage

#+BEGIN_SRC crystal require "deep-merge" #+END_SRC

=Hash= is now monkey-patched to support =.deep_merge= and =.deep_merge!= instance methods.

** TODO Add support for:

  • arrays (probably configurable) #+BEGIN_SRC crystal { "a" => [ "b" ] }.deep_merge({ "a" => [ "c" ] }) => { "a" => [ "b", "c" ] } #+END_SRC
  • arrays of Hashes
  • Development / Contributing
  1. Fork it (https://github.com/peterhoeg/deep-merge/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Merge Request
  • Contributors
  • [[https://github.com/peterhoeg][peterhoeg]] Peter Hoeg - creator, maintainer
Repository

deep-merge.cr

Owner
Statistic
  • 2
  • 0
  • 0
  • 0
  • 0
  • over 2 years ago
  • August 29, 2018
License

MIT License

Links
Synced at

Fri, 03 May 2024 08:13:16 GMT

Languages