Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
mergee
Advanced tools
Readme
Utilities for objects
This is a selection of utilities for objects and contains:
extend object target
with multiple source
objects
var extend = require('mergee').extend,
target = { a:{A:1}, b:{A:1} },
source1 = { b:{B:2}, c:{B:2} },
source2 = { d:{C:3} };
extend(target, source1, source2);
// target === { a:{A:1}, b:{B:2}, c:{B:2}, d:{C:3} };
Parameters
target: Object | Array | function
, extend object target
with multiple source
objects
var extend = require('mergee').extend,
target = { a:{A:1}, b:{A:1} },
source1 = { b:{B:2}, c:{B:2} },
source2 = { d:{C:3} };
extend(target, source1, source2);
// target === { a:{A:1}, b:{B:2}, c:{B:2}, d:{C:3} };
source: Any
, arguments 2 ... n
Returns: Object
, extended target
merge multiple objects into target
var merge = require('mergee').merge,
target = { t: 1, x: { y: 'z' } },
source1 = { t: { s1: /source1/ } },
source2 = { t: { s2: new Date(100), x: null } };
merge(target, source1, source2);
// target === { t: { s1: /source1/, s2: Wed Dec 31 1969 17:00:00 GMT-0700 (MST) }, x: null }
Parameters
target: Object | function | Array
, target object
source: Any
, arguments 2 ... n
Returns: Object
, merged target
extended merge
var merge = require('mergee').merge,
target = { t: 1, x: { y: 'z' } },
source1 = { t: { s1: /source1/ } },
source2 = { t: { s2: new Date(100), x: null } };
mergeExt({ ignoreNull: true }, target, source1, source2);
// target === { t: { s1: /source1/, s2: Wed Dec 31 1969 17:00:00 GMT-0700 (MST) }, x: { y: 'z' } }
Parameters
opts: Object
, options
opts.ignoreNull: Boolean
, treat source === null
as undefined - target does not get deleted
opts.ignoreCircular: Boolean
, ignore cirular structures - no error gets thrown
target: Object | function | Array
, target object
source: Any
, arguments 3 ... n
Returns: Object
, merged target
perform a deep clone of obj
var clone = require('mergee').clone,
obj = { a: { b: { c: 1 } } };
var cloned = clone(obj);
// (cloned !== obj)
// (cloned.a !== obj.a)
// (cloned.a.b !== obj.a.b)
Parameters
obj: Object | Array
, object to get cloned
Returns: Object | Array
, deep cloned object
pick properties from obj
into a new object
var r,
pick = require('mergee').pick,
obj = { a:1, b:2, c:3, d:4 };
r = pick(o, ['a', 'd']);
// r = { a:1, d: 4 }
r = pick(o, 'a,d');
// r = { a:1, d: 4 }
Parameters
obj: Object
, object to pick properties from
keys: Array | String
, Array of properties or comma separated string of properties
Returns: Object
, object with picked properties
omit properties from obj
into a new object
var r,
omit = require('mergee').omit,
obj = { a:1, b:2, c:3, d:4 };
r = omit(o, ['a', 'd']);
// r = { b:2, c: 3 }
r = omit(o, 'a,d');
// r = { b:2, c: 3 }
Parameters
obj: Object
, object
keys: Array | String
, Array of properties or comma separated string of properties
Returns: Object
, object with omitted properties
select properties from obj
var r,
select = require('mergee').select,
obj = { a: { b: { c: 1 } } };
r = select(obj, [a, b, c]);
// r = 1
r = select(obj, 'a.b.c');
// r = 1
r = select(obj, 'there.is.no.such.property'); // this will not throw!
// r = undefined
Parameters
obj: Object
, object to select from
keys: Array | String
, Array of properties or dot separated string of properties
Returns: Object
, selected object
check if an object obj
contains circular structures
var isCircular = require('mergee').isCircular,
obj = { a: {} };
obj.a.c = { c: 1 };
// isCircular(obj) === true
Parameters
obj: Object
, Object to check
Returns: Boolean
, true if obj
contains circularities
deep comparison of actual
and expected
Parameters
actual: Any
, deep comparison of actual
and expected
expected: Any
, deep comparison of actual
and expected
Returns: Boolean
, true if actual
equals expected
If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work or correctly attributed with the source of its origin and licence.
This module contains code from other MIT licensed sources:
lib/deepequal.js
is from node v0.12 assert.js - MIT licensedlib/util.js
is from node v0.12 util.js - MIT licensedCopyright (c) 2015 commenthol (MIT License)
See LICENSE for more info.
FAQs
Unknown package
The npm package mergee receives a total of 6,789 weekly downloads. As such, mergee popularity was classified as popular.
We found that mergee demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.