Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Micro-lib for performing shallow/deep copying of objects with support for array merging + dedup
#blend.js Micro-lib for performing shallow/deep copying of objects with support for array merging + dedup
blend
is NOT a direct port of jQuery's extend() method. This lib follows the same approach that jQuery.extend does
except it will handle the deep copying of arrays differently. jQuery will overwrite the index of an array during a deep copy
where as blend will merge the contents of the arrays, and dedup if defined.
This package is available on npm as: blend.js
npm install blend.js
bower install blend.js
// include the file inside your app
<script type="text/javascript" src="/bower_components/blend/lib/blend.min.js"></script>
Merge the contents of two or more objects into the target object.
Syntax: blend ( [deep
], [dedup
], target
, object1
, [objectN
] )
deep
Boolean
If true, the merge becomes recursive (optional)
dedup
Boolean
If true, arrays will be dedupped during deep copy (optional)
target
Object
The object receiving the new properties
objectN
Object (Optional)
One or more additional objects to merge with the first
Example:
Shallow copy:
var blend = require('blend'), // window.blend for browsers (`blend` is global)
target = {
test: 'me'
},
object1 = {
hello: {
name: 'world',
ids: [1,2,3,4]
}
},
object2 = {
hello: {
first: 'kieran',
ids: [4,5,6,7]
}
};
blend(target, object1, object2);
// output
{
test: 'me',
hello: {
first: 'kieran',
ids: [4,5,6,7]
}
}
Deep copy:
blend(true, target, object1, object2);
// output
{
test: 'me',
hello: {
first: 'kieran',
name: 'world',
ids: [1,2,3,4,4,5,6,7]
}
}
Deep copy + dedup:
blend(true, true, target, object1, object2);
// output
{
test: 'me',
hello: {
first: 'kieran',
name: 'world',
ids: [1,2,3,4,5,6,7]
}
}
Credit to jQuery for the foundation of this utility function.
FAQs
Micro library for performing shallow/deep copying of objects with support for array merging + dedup
The npm package blend.js receives a total of 2 weekly downloads. As such, blend.js popularity was classified as not popular.
We found that blend.js 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
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.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.