AhMyth 9000392778 beta version 8 yıl önce
..
.editorconfig 9000392778 beta version 8 yıl önce
.gitattributes 9000392778 beta version 8 yıl önce
.jshintrc 9000392778 beta version 8 yıl önce
.npmignore 9000392778 beta version 8 yıl önce
.travis.yml 9000392778 beta version 8 yıl önce
LICENSE 9000392778 beta version 8 yıl önce
README.md 9000392778 beta version 8 yıl önce
index.js 9000392778 beta version 8 yıl önce
package.json 9000392778 beta version 8 yıl önce
test.js 9000392778 beta version 8 yıl önce

README.md

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.