Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
async-done
Advanced tools
Readme
Allows libraries to handle various caller provided asynchronous functions uniformly. Maps promises, observables, child processes and streams, and callbacks to callback style.
As async conventions evolve, it is useful to be able to deal with several different styles of async completion uniformly. With this module you can handle completion using a node-style callback, regardless of a return value that's a promise, observable, child process or stream.
var asyncDone = require('async-done');
asyncDone(
function (done) {
// do async things
done(null, 2);
},
function (error, result) {
// `error` will be null on successful execution of the first function.
// `result` will be the result from the first function.
}
);
var asyncDone = require('async-done');
asyncDone(
function (done) {
// do async things
done(new Error('Some Error Occurred'));
},
function (error, result) {
// `error` will be an error from the first function.
// `result` will be undefined on failed execution of the first function.
}
);
asyncDone(fn, callback)
Takes a function to execute (fn
) and a function to call on completion (callback
).
fn([done])
Optionally takes a callback to call when async tasks are complete.
Callback
(done
) called
Stream
or EventEmitter
returned
event-stream
are not supported.Child Process
returned
Promise
returned
Observable
(e.g. from RxJS v5 or RxJS v4) returned
Warning: Sync tasks are not supported and your function will never complete if the one of the above strategies is not used to signal completion. However, thrown errors will be caught by the domain.
callback(error, result)
If an error doesn't occur in the execution of the fn
function, the callback
method will receive the results as its second argument. Note: Some streams don't received any results.
If an error occurred in the execution of the fn
function, The callback
method will receive an error as its first argument.
Errors can be caused by:
done
callbackerror
event emitted on a returned Stream
, EventEmitter
or Child Process
Promise
- If the Promise
is not rejected with a value, we generate a new Error
onError
handler being called on an Observable
MIT
FAQs
Allows libraries to handle various caller provided asynchronous functions uniformly. Maps promises, observables, child processes and streams, and callbacks to callback style.
The npm package async-done receives a total of 1,472,149 weekly downloads. As such, async-done popularity was classified as popular.
We found that async-done demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.