Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weavejester/meta-merge
A standalone implementation of Leiningen's meta-merge function
https://github.com/weavejester/meta-merge
Last synced: about 1 month ago
JSON representation
A standalone implementation of Leiningen's meta-merge function
- Host: GitHub
- URL: https://github.com/weavejester/meta-merge
- Owner: weavejester
- Created: 2014-10-05T19:42:27.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-13T14:49:33.000Z (about 1 year ago)
- Last Synced: 2024-10-28T13:37:48.908Z (about 2 months ago)
- Language: Clojure
- Size: 12.7 KB
- Stars: 105
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- stars - weavejester/meta-merge - A standalone implementation of Leiningen's meta-merge function (⭐️106) (Clojure)
- stars - weavejester/meta-merge - A standalone implementation of Leiningen's meta-merge function (⭐️106) (Clojure)
README
# Meta-Merge
[![Build Status](https://travis-ci.org/weavejester/meta-merge.svg?branch=master)](https://travis-ci.org/weavejester/meta-merge)
This is a standalone implementation of the [Leiningen][] `meta-merge`
function. It's particularly useful for merging configuration maps.[Leiningen]: https://github.com/technomancy/leiningen
## Installation
To install, add the following to your project `:dependencies`:
[meta-merge "1.0.0"]
## Usage
The `meta-merge` function recursively merges two data structures.
```clojure
(require '[meta-merge.core :refer [meta-merge]])(meta-merge {:a [:b :c]} {:a [:d]})
=> {:a [:b :c :d]}
```## Metadata
Metadata hints can be provided to override the default behavior:
### Prepend
When `meta-merge` is called with a hash-map that has `^:prepend` on it, the
function will take the values on the right and prepend them to the set on the
left (the default would **append** them as you can see above). You can see this
below.```clojure
(meta-merge {:a [:b :c]} {:a ^:prepend [:d]})
=> {:a [:d :b :c]}
```### Replace
When `meta-merge` is called with a hash-map that has `^:replace` on it, the
function will take the values on the right and completely replace the ones on
the left. You can see this below:```clojure
(meta-merge {:a [:b :c]} {:a ^:replace [:d]})
=> {:a [:d]}
```With replace the map to the right takes precedence.
### Displace
When `meta-merge` is called with a hash-map that has `^:displace` on it, the
function will take the values on the right, only if there are no values on the
left. You can see this below:```clojure
(meta-merge {:a [:b :c]} {:a ^:displace [:d]})
=> {:a [:b :c]}
```With displace the map to the left takes precedence. This makes displace a
good solution for default values.## License
Copyright © 2016 Phil Hagelberg, James Reeves and all the Leiningen
[contributors][].Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.[contributors]: https://github.com/technomancy/leiningen/graphs/contributors