first commit
This commit is contained in:
12
build/node_modules/run-async/.editorconfig
generated
vendored
Normal file
12
build/node_modules/run-async/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
1
build/node_modules/run-async/.gitattributes
generated
vendored
Normal file
1
build/node_modules/run-async/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
20
build/node_modules/run-async/.jshintrc
generated
vendored
Normal file
20
build/node_modules/run-async/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"node": true,
|
||||
"esnext": true,
|
||||
"bitwise": false,
|
||||
"curly": false,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"immed": true,
|
||||
"latedef": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"undef": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"indent": 2,
|
||||
"quotmark": "single",
|
||||
"scripturl": true,
|
||||
"globals": [ "describe", "it" ]
|
||||
}
|
||||
1
build/node_modules/run-async/.npmignore
generated
vendored
Normal file
1
build/node_modules/run-async/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
3
build/node_modules/run-async/.travis.yml
generated
vendored
Normal file
3
build/node_modules/run-async/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
21
build/node_modules/run-async/LICENSE
generated
vendored
Normal file
21
build/node_modules/run-async/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Simon Boudrias
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
50
build/node_modules/run-async/README.md
generated
vendored
Normal file
50
build/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.
|
||||
25
build/node_modules/run-async/index.js
generated
vendored
Normal file
25
build/node_modules/run-async/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var once = require('once');
|
||||
|
||||
/**
|
||||
* Run a function asynchronously or synchronously
|
||||
* @param {Function} func Function to run
|
||||
* @param {Function} cb Callback function passed the `func` returned value
|
||||
* @...rest {Mixed} rest Arguments to pass to `func`
|
||||
* @return {Null}
|
||||
*/
|
||||
|
||||
module.exports = function (func, cb) {
|
||||
var async = false;
|
||||
var answer = func.apply({
|
||||
async: function () {
|
||||
async = true;
|
||||
return once(cb);
|
||||
}
|
||||
}, Array.prototype.slice.call(arguments, 2) );
|
||||
|
||||
if (!async) {
|
||||
cb(answer);
|
||||
}
|
||||
};
|
||||
58
build/node_modules/run-async/package.json
generated
vendored
Normal file
58
build/node_modules/run-async/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"_from": "run-async@^0.1.0",
|
||||
"_id": "run-async@0.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=",
|
||||
"_location": "/run-async",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "run-async@^0.1.0",
|
||||
"name": "run-async",
|
||||
"escapedName": "run-async",
|
||||
"rawSpec": "^0.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/inquirer"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz",
|
||||
"_shasum": "c8ad4a5e110661e402a7d21b530e009f25f8e389",
|
||||
"_spec": "run-async@^0.1.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/inquirer",
|
||||
"author": {
|
||||
"name": "Simon Boudrias",
|
||||
"email": "admin@simonboudrias.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/SBoudrias/run-async/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"once": "^1.3.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.",
|
||||
"devDependencies": {
|
||||
"mocha": "^1.21.4"
|
||||
},
|
||||
"homepage": "https://github.com/SBoudrias/run-async",
|
||||
"keywords": [
|
||||
"flow",
|
||||
"flow-control",
|
||||
"async"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "run-async",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/SBoudrias/run-async.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha -R spec"
|
||||
},
|
||||
"version": "0.1.0"
|
||||
}
|
||||
51
build/node_modules/run-async/test.js
generated
vendored
Normal file
51
build/node_modules/run-async/test.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var runAsync = require('./index');
|
||||
|
||||
describe('runAsync', function () {
|
||||
it('run synchronous method', function (done) {
|
||||
var aFunc = function () {
|
||||
return 'pass1';
|
||||
};
|
||||
runAsync(aFunc, function (val) {
|
||||
assert.equal(val, 'pass1');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('run asynchronous method', function (done) {
|
||||
var aFunc = function () {
|
||||
var returns = this.async();
|
||||
setTimeout(returns.bind(null, 'pass2'), 0);
|
||||
};
|
||||
|
||||
runAsync(aFunc, function (val) {
|
||||
assert.equal(val, 'pass2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('pass arguments', function (done) {
|
||||
var aFunc = function (a, b) {
|
||||
assert.equal(a, 1);
|
||||
assert.equal(b, 'bar');
|
||||
return 'pass1';
|
||||
};
|
||||
runAsync(aFunc, function (val) {
|
||||
done();
|
||||
}, 1, 'bar');
|
||||
});
|
||||
|
||||
it('allow only callback once', function (done) {
|
||||
var aFunc = function () {
|
||||
var returns = this.async();
|
||||
returns();
|
||||
returns();
|
||||
};
|
||||
|
||||
runAsync(aFunc, function (val) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user