https://github.com/peterhoeg/deep-merge.cr
Deep merge support for Hash
https://github.com/peterhoeg/deep-merge.cr
Last synced: about 1 year ago
JSON representation
Deep merge support for Hash
- Host: GitHub
- URL: https://github.com/peterhoeg/deep-merge.cr
- Owner: peterhoeg
- License: mit
- Created: 2020-05-02T23:17:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-11-15T00:27:57.000Z (over 4 years ago)
- Last Synced: 2025-02-05T21:58:07.079Z (over 1 year ago)
- Language: Crystal
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* deep-merge
[[https://github.com/peterhoeg/deep-merge.cr/workflows/Crystal%20CI/badge.svg]]
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 ()
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