
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
chain-methods
Advanced tools
This module exposes a single function to transform a plain object into a class, where methods can be chained.
npm install chain-methods
const chainMethods = require('chain-methods');
const Path = chainMethods(require('path'));
const rootPath = new Path(__dirname);
const imagesPath = rootPath.join('dist/static/images');
// With `chainMethods`:
const stream = fs.createReadStream(imagesPath.join('foo.jpg').value);
This module was created for experimentation purposes. It works well for APIs like node's path and url modules, where the first argument of each function is consistent.
It makes code a little easier to read by avoiding this type of nesting:
const foo = obj.method1(obj.method2('bar'), 'baz');
The first argument of each method must be consistent.
const Calculator = chainMethods({
// Good:
add: (n1, n2) => n1 + n2,
subtract: (n1, n2) => n1 - n2,
// Bad:
operation(operationName, ...args) {
return this[operationName](...args);
},
});
const value = new Calculator(0)
.add(10)
.subtract(2)
// This line won't work because of the argument order of `operation`:
.operation('add', 20)
.value;
In the example above, the first argument of operation
is not the number being
operated on. It is inconsistent with add
and subtract
, so will not work in
chaining.
FAQs
Create a class to chain methods from an object.
We found that chain-methods 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.