Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
hooks-mixin
Advanced tools
A small mixin for classes. Adds hooks ability to your classes
yarn add hooks-mixin
npm i hooks-mixin
const HooksMixin = require('hooks-mixin');
class Class {
async save() {
// sync hook call
this.processHooks('pre-save');
await this.write();
// async hook call
await this.processHooksAsync('saved');
return this;
}
};
HooksMixin(Class);
const instance = new Class();
// add hook
instance.hook('pre-save', (instance) => {
// instance — is an instance this
// things with instance
});
instance.save();
// will call pre-save and saved hooks
You can add many hooks:
instance.hook('pre-save', () => console.info('One'));
instance.hook('pre-save', () => console.info('Two'));
instance.hook('saved', () => console.info('Three'));
instance.hook('saved', () => console.info('Four'));
instance.save();
// One, Two, Three, Four
const preSaveHookFunction = () => console.info('=)');
instance.hook('pre-save', preSaveHookFunction);
instance.save();
// =)
instance.removeHook('pre-save', preSaveHookFunction);
instance.save();
// no “=)”
FAQs
A small mixin for classes. Adds hooks ability to your classes
The npm package hooks-mixin receives a total of 5 weekly downloads. As such, hooks-mixin popularity was classified as not popular.
We found that hooks-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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.