async-done

WebJar for async-done

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

async-done
Last Version

Last Version

1.3.2
Release Date

Release Date

Type

Type

jar
Description

Description

async-done
WebJar for async-done
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/gulpjs/async-done

Download async-done

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/async-done/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>async-done</artifactId>
    <version>1.3.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/async-done/
implementation 'org.webjars.npm:async-done:1.3.2'
// https://jarcasting.com/artifacts/org.webjars.npm/async-done/
implementation ("org.webjars.npm:async-done:1.3.2")
'org.webjars.npm:async-done:jar:1.3.2'
<dependency org="org.webjars.npm" name="async-done" rev="1.3.2">
  <artifact name="async-done" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='async-done', version='1.3.2')
)
libraryDependencies += "org.webjars.npm" % "async-done" % "1.3.2"
[org.webjars.npm/async-done "1.3.2"]

Dependencies

compile (4)

Group / Artifact Type Version
org.webjars.npm : end-of-stream jar [1.1.0,2)
org.webjars.npm : once jar [1.3.2,2)
org.webjars.npm : process-nextick-args jar [2.0.0,3)
org.webjars.npm : stream-exhaust jar [1.0.1,2)

Project Modules

There are no modules declared in this project.

async-done

NPM version Downloads Azure Pipelines Build Status Travis Build Status AppVeyor Build Status Coveralls Status Gitter chat

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.

Usage

Successful completion

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.
});

Failed completion

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.
});

API

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.

Completion and Error Resolution

  • Callback (done) called
    • Completion: called with null error
    • Error: called with non-null error
  • Stream or EventEmitter returned
    • Completion: end-of-stream module
    • Error: domains
    • Note: Only actual streams are supported, not faux-streams; Therefore, modules like 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:

  • A thrown error
  • An error passed to a done callback
  • An error event emitted on a returned Stream, EventEmitter or Child Process
  • A rejection of a returned Promise - If the Promise is not rejected with a value, we generate a new Error
  • The onError handler being called on an Observable

License

MIT

org.webjars.npm

gulp

A toolkit to automate & enhance your workflow

Versions

Version
1.3.2
1.3.1