node/tools/eslint/node_modules/run-async
Rich Trott e313c0286b tools: update to ESLint 3.2.2
PR-URL: https://github.com/nodejs/node/pull/7999
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2016-08-09 21:19:02 -07:00
..
index.js tools: update eslint to v1.10.3 2016-01-13 23:15:39 +01:00
LICENSE tools: update eslint to v1.10.3 2016-01-13 23:15:39 +01:00
package.json tools: update to ESLint 3.2.2 2016-08-09 21:19:02 -07:00
README.md tools: update ESLint to 2.9.0 2016-05-04 10:26:25 -07:00

Run Async

npm tests dependencies

Utility method to run function either synchronously or asynchronously using the common this.async() style.

This is useful for library author accepting sync or async functions as parameter. runAsync will always run them as async method, and normalize the function handling.

Installation

npm install --save run-async

Usage

var runAsync = require('run-async');

// In Async mode:
var asyncFn = function (a) {
  var done = this.async();

  setTimeout(function () {
    done('running: ' + a);
  }, 10);
};

runAsync(asyncFn, function (answer) {
  console.log(answer); // 'running: async'
}, 'async');

// In Sync mode:
var syncFn = function (a) {
  return 'running: ' + a;
};

runAsync(asyncFn, function (answer) {
  console.log(answer); // 'running: sync'
}, 'sync');

Licence

Copyright (c) 2014 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.