Skip to content

swordev/merge

Repository files navigation

merge

workflow-badge license-badge

(recursive)? merging of (cloned)? objects.

Installation

npm install merge

Usage

API

merge(clone: boolean, ...items: Object[])
merge(...items: Object[])
merge.recursive(clone: boolean, ...items: Object[])
merge.recursive(...items: Object[])

Examples

const objectA = {};

merge(objectA, { value: 1 }, { str: "hello world" });

const objectB = merge(true, objectA, { value: 2 });

objectA; // { value: 1, str: 'hello world' }
objectB; // { value: 2, str: 'hello world' }
const objectA = {};

merge.recursive(
  objectA,
  { level: { value: 1 } },
  { level: { str: "hello world" } },
);
const objectB = merge.recursive(true, objectA, { level: { value: 2 } });

objectA.level; // { value: 1, str: 'hello world' }
objectB.level; // { value: 2, str: 'hello world' }

Development

Requirements

Build

pnpm build

Test

pnpm test

License

Distributed under the MIT License. See LICENSE file in each package for more information.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6