{ "_args": [ [ { "raw": "run-async@^2.2.0", "scope": null, "escapedName": "run-async", "name": "run-async", "rawSpec": "^2.2.0", "spec": ">=2.2.0 <3.0.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/inquirer" ] ], "_from": "run-async@>=2.2.0 <3.0.0", "_id": "run-async@2.3.0", "_inCache": true, "_location": "/run-async", "_nodeVersion": "7.0.0", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/run-async-2.3.0.tgz_1480655904296_0.6874290609266609" }, "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "_npmVersion": "3.10.8", "_phantomChildren": {}, "_requested": { "raw": "run-async@^2.2.0", "scope": null, "escapedName": "run-async", "name": "run-async", "rawSpec": "^2.2.0", "spec": ">=2.2.0 <3.0.0", "type": "range" }, "_requiredBy": [ "/inquirer" ], "_resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", "_shasum": "0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0", "_shrinkwrap": null, "_spec": "run-async@^2.2.0", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/inquirer", "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "dependencies": { "is-promise": "^2.1.0" }, "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "devDependencies": { "mocha": "^3.1.2" }, "directories": {}, "dist": { "shasum": "0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz" }, "engines": { "node": ">=0.12.0" }, "files": [ "index.js" ], "gitHead": "23767c9d7eaf6a6bb1241fc9e12776685258c50e", "homepage": "https://github.com/SBoudrias/run-async#readme", "keywords": [ "flow", "flow-control", "async" ], "license": "MIT", "main": "index.js", "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "name": "run-async", "optionalDependencies": {}, "readme": "Run Async\n=========\n\n[![npm](https://badge.fury.io/js/run-async.svg)](http://badge.fury.io/js/run-async) [![tests](https://travis-ci.org/SBoudrias/run-async.svg?branch=master)](http://travis-ci.org/SBoudrias/run-async) [![dependencies](https://david-dm.org/SBoudrias/run-async.svg?theme=shields.io)](https://david-dm.org/SBoudrias/run-async)\n\nUtility method to run a function either synchronously or asynchronously using a series of common patterns. This is useful for library author accepting sync or async functions as parameter. `runAsync` will always run them as an async method, and normalize the multiple signature.\n\nInstallation\n=========\n\n```bash\nnpm install --save run-async\n```\n\nUsage\n=========\n\nHere's a simple example print the function results and three options a user can provide a function.\n\n```js\nvar runAsync = require('run-async');\n\nvar printAfter = function (func) {\n var cb = function (err, returnValue) {\n console.log(returnValue);\n };\n runAsync(func, cb)(/* arguments for func */);\n};\n```\n\n#### Using `this.async`\n```js\nprintAfter(function () {\n var done = this.async();\n\n setTimeout(function () {\n done(null, 'done running with callback');\n }, 10);\n});\n```\n\n#### Returning a promise\n```js\nprintAfter(function () {\n return new Promise(function (resolve, reject) {\n resolve('done running with promises');\n });\n});\n```\n\n#### Synchronous function\n```js\nprintAfter(function () {\n return 'done running sync function';\n});\n```\n\n### runAsync.cb\n\n`runAsync.cb` supports all the function types that `runAsync` does and additionally a traditional **callback as the last argument** signature:\n\n```js\nvar runAsync = require('run-async');\n\n// IMPORTANT: The wrapped function must have a fixed number of parameters.\nrunAsync.cb(function(a, b, cb) {\n cb(null, a + b);\n}, function(err, result) {\n console.log(result)\n})(1, 2)\n```\n\nIf your version of node support Promises natively (node >= 0.12), `runAsync` will return a promise. Example: `runAsync(func)(arg1, arg2).then(cb)`\n\nLicence\n========\n\nCopyright (c) 2014 Simon Boudrias (twitter: @vaxilart) \nLicensed under the MIT license.\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/SBoudrias/run-async.git" }, "scripts": { "test": "mocha -R spec" }, "version": "2.3.0" }