Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

async-settle

Package Overview
Dependencies
1
Maintainers
2
Versions
6
Issues
File Explorer

Advanced tools

async-settle

Settle an async function.

    2.0.0latest

Version published
Maintainers
2
Weekly downloads
1,345,651
increased by16.22%

Weekly downloads

Changelog

Source

2.0.0 (2022-06-25)

⚠ BREAKING CHANGES

  • Normalize repository, dropping node <10.13 support (#16)

Miscellaneous Chores

  • Normalize repository, dropping node <10.13 support (#16) (bf4ba5a)

Readme

Source

async-settle

NPM version Downloads Build Status Coveralls Status

Settle an async function. It will always complete successfully with an object of the resulting state.

Handles completion and errors for callbacks, promises, observables and streams.

Will run call the function on nextTick. This will cause all functions to be async.

Usage

Successful completion

var asyncSettle = require('async-settle'); asyncSettle( function (done) { // do async things done(null, 2); }, function (error, result) { // `error` will ALWAYS be null on execution of the first function. // `result` will ALWAYS be a settled object with the result or error of the first function. } );

Failed completion

var asyncSettle = require('async-settle'); asyncSettle( function (done) { // do async things done(new Error('Some Error Occurred')); }, function (error, result) { // `error` will ALWAYS be null on execution of the first function. // `result` will ALWAYS be a settled object with the result or error of the first function. } );

API

asyncSettle(fn, callback)

Takes a function to execute (fn) and a function to call on completion (callback).

fn([done])

Optionally takes a callback (done) to call when async tasks are complete.

Executed in the context of async-done, with all errors and results being settled.

Completion is handled by async-done completion and error resolution.

callback(error, result)

Called on completion of fn and recieves a settled object as the result argument.

The error argument will always be null.

Settled Object

Settled values have two properties, state and value.

state has two possible options 'error' and 'success'.

value will be the value passed to original callback.

License

MIT

Keywords

FAQs

What is async-settle?

Settle an async function.

Is async-settle popular?

The npm package async-settle receives a total of 1,082,550 weekly downloads. As such, async-settle popularity was classified as popular.

Is async-settle well maintained?

We found that async-settle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 25 Jun 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc