Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
make an object's functions chainable.
var chaingun = require('chaingun');
var chain = chaingun({
add: function(a, b) { return a + b; },
multiply: function(a, b) { return a * b; }
});
chain(2)
.add(3)
.multiply(5)
.add(5)
.multiply(2)
(); // 60
node:
$ npm install chaingun
browser:
$ bower install chaingun
<script src="/bower_components/chaingun/chaingun.js"></script>
chaingun(obj)
Returns a chainable version of the given object.
When the chainable is invoked, a chain is started. A chain consists of 'curried' versions of the original object's enumerable function properties. Each function invoked in the chain will be curried with the chain's current value, and its result used as the chain's new value. The given value will be used as the starting value for the chain. When the chain is invoked directly, its value is returned:
var chain = chaingun({add: function(a, b) { return a + b; }});
chain(2)
.add(3)
.add(5);
() // 10
If obj
is a function, it will be invoked at the start of the chain. Its return value will be used as the starting value of the chain:
function thing(a, b) { return a + b; }
thing.multiply = function(a, b) { return a * b; };
var chain = chaingun(thing);
chain(2, 3)
.multiply(4)
(); // 20
obj
's properties can be accessed directly from the chainable:
var obj = {
foo: 2,
bar: 3,
baz: {},
quux: function() {}
};
var chain = chaingun(obj);
chain.foo === obj.foo; // true
chain.bar === obj.bar; // true
chain.baz === obj.baz; // true
chain.quux === obj.quux; // true
FAQs
make an object's functions chainable
We found that chaingun 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.