Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
object-assign-deep
Advanced tools
Allows deep cloning of plain objects that contain primitives, nested plain objects, or nested plain arrays.
Like Object.assign() but deeper. This module is the holy grail of simple object manipulation in JavaScript and it does not resort to using the JSON functions.
This module is to be used with PLAIN objects that contain primitive values ONLY. Every time you misuse this module a kitten dies.. yes you're a kitten killer.
Do not use this module if:
If you need to do something fancy like the above there are better solutions out there.
This module does NOT mutate the first parameter like Object.assign(), instead it always returns a new object with all the properties copied across and the parameters left intact.
You can merge plain objects or clone them:
const objectAssignDeep = require(`object-assign-deep`);
const mergedObjects = objectAssignDeep(object1, object2, ...objectN);
const clonedObject = objectAssignDeep(originalObject);
Simples!
See the ./examples
directory for a few examples, including one example case that demonstrates why you can't get clever with object cloning.
const objectAssignDeep = require(`object-assign-deep`);
const objectA = {
prop1: `Hello`,
prop2: `World`,
nested: {
bool: true,
super: 123,
still: `here!`,
},
array1: [1, 2, 3],
array2: [4, 5, 6],
};
const objectB = {
prop2: `Universe`,
name: `Josh`,
nested: {
bool: false,
},
array1: null,
};
const objectC = {
location: `United Kingdom`,
name: `Bob`,
nested: {
super: 999,
},
};
const result = objectAssignDeep(objectA, objectB, objectC);
console.log(`Result:`, result);
/*
* {
* prop1: 'Hello',
* prop2: 'Universe',
* nested: { bool: false, super: 999, still: 'here!' },
* array1: null,
* array2: [ 4, 5, 6 ],
* name: 'Bob',
* location: 'United Kingdom'
* }
*/
FAQs
Allows deep cloning of plain objects that contain primitives, nested plain objects, or nested plain arrays.
The npm package object-assign-deep receives a total of 28,816 weekly downloads. As such, object-assign-deep popularity was classified as popular.
We found that object-assign-deep 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.