Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
The name is short for extend-object-ownkeys; hat tip to @henrikjoreteg for 'extend-object' which does pretty much the same thing as this, but uses for … in
to match Underscore.js instead of Object.keys
to match ???. See also 'extend' if you want all the $.extend features.
var extend = require('xok'),
assert = function (ok) { if (!ok) throw Error(); };
// use for shallow copies
var sampleObj = {abc:123,def:42},
shallowClone = extend({}, sampleObj);
assert('abc' in shallowClone);
shallowClone.def = 0;
assert(sampleObj.def === 42);
// or defaulting options!
function test(opts) {
opts = extend({
foo: true,
bar: 'someDefault'
}, opts);
return (opts.foo) ? opts.bar : null;
}
assert(test() === 'someDefault');
assert(test({bar:'customValue'}) === 'customValue');
assert(test({foo:false}) === null);
extend = require('xok')
— this module exports a single function.extend(target, …)
— returns target
after going through all the following arguments and shallow-copying the objects' own properties into it. The extra arguments may be null
(anything false
y really) but are otherwise expected to be objects and not strings or cheeses or wild animals or whatever.Solipsistic Public License; see LICENSE file for details.
FAQs
Extend an object with the "has own property"'s of other object(s)
The npm package xok receives a total of 6,953 weekly downloads. As such, xok popularity was classified as popular.
We found that xok 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.