Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A light and easy to use interface for creating fluent, chainable javascript APIs in Node.js or PhantomJs
When performing many asynchronous operations in javascript, nested callbacks can become difficult to read and maintain. Api-chain is a very light and easy to use interface for creating a fluent synchronous style API for control flow of asynchronous javascript. It is packaged as a commonJS module through NPM but not only works with Node.js, but has been tested and works with PhantomJS as well.
Methods can pass values down the chain by invoking next with them, e.g. next(null, value). Node.js callback style methods will be wrapped automatically so as to pass the results down the chain.
npm install api-chain
// require api-chain module
var api = require('api-chain');
// define your api by passing methods to create
var fs = api.create({
read: require('fs').readFile,
toString: function (data, next) {
next(null, data.toString());
},
view: function (contents) {
console.log(contents);
}
});
// example using the chainable 'fs' API as created above
fs.read('./index.js')
.toString()
.view();
For more examples look in the examples subdirectory.
name | type | default | description |
---|---|---|---|
onError | fn | undefined | called when error is emitted unless error method is overwritten |
throwErrors | bool | true | whether to throw unhandled errors (ignored if onError exists) |
continueErrors | bool | false | whether to resume execution of commands after errors occur |
api.wait(n) - pause execution flow for n milliseconds
api.until(fn) - wait until callback fn returns true before continuing execution flow
api.chain(fn) - add callback fn to be executed next in the control flow stack.
api.set(name, value, [immediate]) - set api object property name to value
api.setOption(option, value) - set option to value
api.setOptions(options) - set several options at once based on options collection of key/value pairs
to test you will need the dev dependencies installed. Just cd to the directory api-chain is installed in and type
npm install
when installation of the dependencies completes, type
npm test
MIT Style License - see license.txt
FAQs
A light and easy to use interface for creating fluent, chainable javascript APIs in Node.js or PhantomJs
The npm package api-chain receives a total of 11 weekly downloads. As such, api-chain popularity was classified as not popular.
We found that api-chain 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.