Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sarukuku/object-joiner
A tiny utility that merges JavaScript objects by bundling clashing property values.
https://github.com/sarukuku/object-joiner
Last synced: about 1 month ago
JSON representation
A tiny utility that merges JavaScript objects by bundling clashing property values.
- Host: GitHub
- URL: https://github.com/sarukuku/object-joiner
- Owner: sarukuku
- Created: 2019-01-23T13:05:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:38:33.000Z (about 2 years ago)
- Last Synced: 2024-10-30T01:34:38.264Z (2 months ago)
- Language: JavaScript
- Homepage: https://npmjs.com/package/object-joiner
- Size: 758 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![](https://img.shields.io/npm/v/object-joiner.svg?style=flat)](https://www.npmjs.com/package/object-joiner) [![](https://img.shields.io/npm/dt/object-joiner.svg?style=flat)](https://www.npmjs.com/package/object-joiner)
# object-joiner
A tiny utility that merges JavaScript objects by bundling clashing property values to arrays instead of overwriting them. Variable number of objects can be passed as arguments.
**Other details**
- Clashing arrays are merged and order of array items preserved
- In objects when a cyclic reference is found it's replaced with a string containing `[Cyclic]`## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save object-joiner
```## Usage
```js
const joinObjects = require('object-joiner')const x = {
a: "a",
b: {
a: "a"
}
}const y = {
b: {
a: "b"
},
c: "c"
}const result = joinObjects(x, y)
/*
> console.log(result)
> {
a: "a",
b: {
a: ["a", "b"]
},
c: "c"
}
* /
```
(see the [`index.test.js`](https://github.com/sarukuku/object-joiner/blob/master/index.test.js) file for more examples)