forked from enviPath/enviPy
Current Dev State
This commit is contained in:
50
static/js/ketcher2/node_modules/run-async/README.md
generated
vendored
Normal file
50
static/js/ketcher2/node_modules/run-async/README.md
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
Run Async
|
||||
=========
|
||||
|
||||
[](http://badge.fury.io/js/run-async) [](http://travis-ci.org/SBoudrias/run-async) [](https://david-dm.org/SBoudrias/run-async)
|
||||
|
||||
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
|
||||
=========
|
||||
|
||||
```bash
|
||||
npm install --save run-async
|
||||
```
|
||||
|
||||
Usage
|
||||
=========
|
||||
|
||||
```js
|
||||
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.
|
||||
Reference in New Issue
Block a user