
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.
Add support for stacked mixins (separate behaviour) into any prototype. Inspired by Vue & React mixins, and Backbone Cocktail.
It is useful to make your views/classes lighter and export common behavior in helpers. Some example use cases:
resize event and calling the appropriate methodinit, render ...)supernpm i trickbag --save
trickbag(object, [mixins...]);
mixins is an object (or an array of objects) containing methods; in other words, of mixins.object is the object to apply these mixins to.Different mixins used on the same object can have methods with identical names.
When the mixins are processed, trickbag properly stack all methods with the same name by wrapping them in a parent method, preserving the call order.
For instance you can have an object with an init method. If your mixin also has the init method, it will be called after the object's one. That allows to easily plug behaviour on your custom classes lifecycle.
var View = function(params) {
trickbag(this, params.mixins);
};
var resizeMixin = {
init: function() {
this.onResize = this.onResize.bind(this);
window.addEventListener('resize', this.onResize);
console.log('Listening to resize')
},
onResize: function() {
this.width = window.innerWidth;
this.height = window.innerHeight;
},
destroy: function() {
window.removeEventListener('resize', this.onResize);
}
};
var fooMixin = {
init: function() {
console.log('Foo foo');
}
}
var v = new View({
mixins: [resizeMixin, fooMixin]
});
v.init(); // "Listening to resize", "Foo foo"
FAQs
Add support for stacked mixins (separate behaviour) into any prototype.
The npm package trickbag receives a total of 3 weekly downloads. As such, trickbag popularity was classified as not popular.
We found that trickbag 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.