
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
object-mixin
Advanced tools
A possible ES6 polyfill
// basic signature
Object.mixin(
target:Object, // the object to be enriched
source:Object // all own properties of this object
// will be assigned using same descriptor
):target // returns the target object modified
// overload with Traits (Function)
Object.mixin(
target:Object, // the object to be enriched
source:Trait // invoked with target as context
[, args:Array|Arguments]
// optional args property
// used at Trait arguments
):target // returns the target object modified
Should be compatible with all JavaScript ES3 or JScript engines.
node.js module, AMD module, and generic env standalone file.
// using an object
var a = {a: 'b'},
b = Object.mixin({b: 'b'}, a);
console.log(JSON.stringify(b));
// {"a":"a","b":"b"}
// using a function
function addUniqueIdFunctionality(prefix) {
var
privatelyShared = {},
i = 0
;
if (!prefix) prefix = '.' + (new Date).getTime();
this.getIdFor = function (key) {
return privatelyShared[key] || (
privatelyShared[key] = ++i + prefix + Math.random()
);
};
}
function GenericClass(){}
Object.mixin(
GenericClass.prototype,
addUniqueIdFunctionality
// , ['my_prefix']
);
var instance1 = new GenericClass,
instance2 = new GenericClass;
console.log([
instance1.getIdFor('a'),
instance1.getIdFor('b'), // different
instance2.getIdFor('a')
// same as instance1.getIdFor('a')
].join('\n'));
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 Andrea Giammarchi <spam@hater.me>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
FAQs
ES6 next big thing polyfilled before it gets real
We found that object-mixin 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.