Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
extend-shallow
Advanced tools
Extend an object with the properties of additional objects. node.js/javascript util.
The extend-shallow npm package is used to copy the properties of one or more source objects to a target object. It is a utility for shallowly extending the properties of objects without deeply cloning them.
Shallow extend one object with another
This feature allows you to extend an object by adding properties from another object. The properties are copied over shallowly, meaning that if the property values are objects, they are not deeply cloned.
{"const extend = require('extend-shallow');
const obj1 = { a: 'a' };
const obj2 = { b: 'b' };
const result = extend(obj1, obj2);
// result is { a: 'a', b: 'b' }"}
Shallow extend with multiple source objects
This feature allows you to extend an object with properties from multiple source objects. The last source's properties will overwrite the properties of the same name in previous sources if they exist.
{"const extend = require('extend-shallow');
const obj1 = { a: 'a' };
const obj2 = { b: 'b' };
const obj3 = { c: 'c' };
const result = extend(obj1, obj2, obj3);
// result is { a: 'a', b: 'b', c: 'c' }"}
The object-assign package is a polyfill for the Object.assign() method, which copies enumerable and own properties from source objects to a target object. It is similar to extend-shallow but is designed to mimic the behavior of the native JavaScript method.
lodash.assign is a method from the Lodash library that assigns own enumerable properties of source objects to the destination object. It is similar to extend-shallow but comes with the additional utility functions provided by Lodash.
deep-extend is similar to extend-shallow but, as the name suggests, performs a deep extend, meaning that it recursively copies property values that are objects, resulting in a deep clone of the source objects' properties.
Extend an object with the properties of additional objects. node.js/javascript util.
npm i extend-shallow --save
npm test
var extend = require('extend-shallow');
extend({a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert
Released under the , licenses
This file was generated by verb on December 05, 2014. To update, run npm i -g verb && verb
.
FAQs
Extend an object with the properties of additional objects. node.js/javascript util.
The npm package extend-shallow receives a total of 53,561,250 weekly downloads. As such, extend-shallow popularity was classified as popular.
We found that extend-shallow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.