Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

merge

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge - npm Package Compare versions

Comparing version 1.2.1 to 2.1.0

lib/src/index.d.ts

66

package.json
{
"name": "merge",
"version": "1.2.1",
"author": "yeikos",
"description": "Merge multiple objects into one, optionally creating a new cloned object. Similar to the jQuery.extend but more flexible. Works in Node.js and the browser.",
"main": "merge.js",
"license": "MIT",
"homepage": "https://github.com/yeikos/js.merge",
"repository": {
"type": "git",
"url": "https://github.com/yeikos/js.merge.git"
},
"keywords": [
"merge",
"recursive",
"extend",
"clone",
"object",
"browser"
],
"scripts": {
"test": "cd tests; node index.js"
}
}
"name": "merge",
"version": "2.1.0",
"author": "yeikos",
"description": "(recursive)? merging of (cloned)? objects.",
"main": "lib/src/index.js",
"files": [
"lib/src/index.d.ts"
],
"license": "MIT",
"homepage": "https://github.com/yeikos/js.merge",
"repository": {
"type": "git",
"url": "https://github.com/yeikos/js.merge.git"
},
"keywords": [
"merge",
"recursive",
"extend",
"clone",
"object",
"browser"
],
"scripts": {
"build": "npm run build:ts && npm run build:wp",
"dev": "./node_modules/.bin/concurrently --kill-others \"npm run dev:ts\" \"npm run dev:wp\"",
"test": "./node_modules/.bin/mocha lib/test/index.js",
"build:ts": "./node_modules/.bin/tsc -p tsconfig.json",
"build:wp": "./node_modules/.bin/webpack --config webpack.config.js",
"dev:ts": "./node_modules/.bin/tsc -p tsconfig.json -w",
"dev:wp": "./node_modules/.bin/webpack --config webpack.config.js -w"
},
"devDependencies": {
"@types/chai": "^4.2.14",
"@types/mocha": "^8.0.4",
"@types/node": "^14.14.7",
"chai": "^4.2.0",
"concurrently": "^5.3.0",
"mocha": "^8.2.1",
"typescript": "^4.0.5",
"webpack": "^5.4.0",
"webpack-cli": "^4.2.0"
}
}
# Merge
Merge multiple objects into one, optionally creating a new cloned object.
Similar to the jQuery.extend but more flexible. Works in Node.js and the
browser.
(recursive)? merging of (cloned)? objects.
## Node.js Usage
# Install
## Node.js
```sh
npm install merge --save
npm i merge
```
```js
import merge from 'merge'
```
## Browser
```html
<script src="https://cdn.jsdelivr.net/gh/yeikos/js.merge/dist/merge.browser.min.js"></script>
```
```js
var merge = require('merge'), original, cloned;
window.merge
```
console.log(merge({one:'hello'}, {two: 'world'}));
// -> {"one": "hello", "two": "world"}
# API
original = { x: { y: 1 } };
cloned = merge(true, original);
cloned.x.y++;
```typescript
merge(clone: boolean, ...items: Object[])
merge(...items: Object[])
merge.recursive(clone: boolean, ...items: Object[])
merge.recursive(...items: Object[])
```
console.log(original.x.y, cloned.x.y);
// -> 1, 2
# Examples
console.log(merge.recursive(true, original, { x: { z: 2 } }));
// -> {"x": { "y": 1, "z": 2 } }
```js
```
// Merge
## Browser Usage
{
var objectA = {}
```html
<script src="https://cdn.jsdelivr.net/gh/yeikos/js.merge/merge.js"></script>
<script>
var original, cloned;
merge(objectA,
{ value: 1 },
{ str: 'hello world' }
)
console.log(merge({one:'hello'}, {two: 'world'}));
// -> {"one": "hello", "two": "world"}
var objectB = merge(true, objectA,
{ value: 2 }
)
original = { x: { y: 1 } };
cloned = merge(true, original);
cloned.x.y++;
objectA // { value: 1, str: 'hello world' }
objectB // { value: 2, str: 'hello world' }
}
console.log(original.x.y, cloned.x.y);
// -> 1, 2
// Recursive merge
console.log(merge.recursive(true, original, { x: { z: 2 } }));
// -> {"x": { "y": 1, "z": 2 } }
{
var objectA = {}
</script>
merge.recursive(objectA,
{ level: { value: 1 } },
{ level: { str: 'hello world' } }
)
var objectB = merge.recursive(true, objectA,
{ level: { value: 2 } }
)
objectA.level // { value: 1, str: 'hello world' }
objectB.level // { value: 2, str: 'hello world' }
}
```
# Test
## Tests
## Node.js

@@ -59,1 +80,6 @@ ```sh

```
## Browser
```
./dist/merge.browser.test.html
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc