{ "_id": "run-async", "_rev": "11-18561bf18e61cdc895a508259e016bf3", "name": "run-async", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "dist-tags": { "latest": "2.4.1" }, "versions": { "0.1.0": { "name": "run-async", "version": "0.1.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "repository": { "type": "git", "url": "git://github.com/SBoudrias/run-async" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "homepage": "https://github.com/SBoudrias/run-async", "dependencies": { "once": "^1.3.0" }, "devDependencies": { "mocha": "^1.21.4" }, "_id": "run-async@0.1.0", "dist": { "shasum": "c8ad4a5e110661e402a7d21b530e009f25f8e389", "tarball": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz" }, "_from": ".", "_npmVersion": "1.4.6", "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "directories": {} }, "1.0.0": { "name": "run-async", "version": "1.0.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "repository": { "type": "git", "url": "git://github.com/SBoudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "homepage": "https://github.com/SBoudrias/run-async", "dependencies": { "is-promise": "^2.1.0", "once": "^1.3.0" }, "devDependencies": { "bluebird": "^2.10.2", "mocha": "^1.21.4" }, "gitHead": "3f7174fac180c9e90bd4ecff9956c2ceb7d731ba", "_id": "run-async@1.0.0", "_shasum": "5a63bec4fdc3331786f9758861a7f27000c0e9e1", "_from": ".", "_npmVersion": "2.14.2", "_nodeVersion": "0.12.7", "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "dist": { "shasum": "5a63bec4fdc3331786f9758861a7f27000c0e9e1", "tarball": "https://registry.npmjs.org/run-async/-/run-async-1.0.0.tgz" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "directories": {} }, "2.0.0": { "name": "run-async", "version": "2.0.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "repository": { "type": "git", "url": "git://github.com/SBoudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "homepage": "https://github.com/SBoudrias/run-async", "dependencies": { "is-promise": "^2.1.0", "once": "^1.3.0", "promise-resolver": "^1.0.0" }, "devDependencies": { "bluebird": "^2.10.2", "mocha": "^1.21.4" }, "gitHead": "80220998e71abb21d87367c562821d23efea2643", "_id": "run-async@2.0.0", "_shasum": "bc9e25f25f40992375f2533aa381e355da412616", "_from": ".", "_npmVersion": "2.14.2", "_nodeVersion": "0.12.7", "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "dist": { "shasum": "bc9e25f25f40992375f2533aa381e355da412616", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.0.0.tgz" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "directories": {} }, "2.1.0": { "name": "run-async", "version": "2.1.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "repository": { "type": "git", "url": "git://github.com/SBoudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "homepage": "https://github.com/SBoudrias/run-async", "dependencies": { "is-promise": "^2.1.0", "promise-resolver": "^3.0.0" }, "devDependencies": { "mocha": "^2.3.3", "pinkie": "^1.0.0" }, "gitHead": "766bfe282253b4c2628ead1b6e6dcf7511a5fcc7", "_id": "run-async@2.1.0", "_shasum": "2505300a22be63202297a9494b6f5f5c441ccd23", "_from": ".", "_npmVersion": "3.5.3", "_nodeVersion": "5.2.0", "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "dist": { "shasum": "2505300a22be63202297a9494b6f5f5c441ccd23", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.1.0.tgz" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "directories": {} }, "2.2.0": { "name": "run-async", "version": "2.2.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "repository": { "type": "git", "url": "git+https://github.com/sboudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "dependencies": { "is-promise": "^2.1.0", "pinkie-promise": "^2.0.0" }, "devDependencies": { "mocha": "^2.3.3" }, "gitHead": "5c6dc70500fd5c0b6ab1ba93f5f1a3338bfeaa84", "bugs": { "url": "https://github.com/sboudrias/run-async/issues" }, "homepage": "https://github.com/sboudrias/run-async#readme", "_id": "run-async@2.2.0", "_shasum": "8783abd83c7bb86f41ee0602fc82404b3bd6e8b9", "_from": ".", "_npmVersion": "3.5.3", "_nodeVersion": "5.2.0", "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "dist": { "shasum": "8783abd83c7bb86f41ee0602fc82404b3bd6e8b9", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.2.0.tgz" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "_npmOperationalInternal": { "host": "packages-13-west.internal.npmjs.com", "tmp": "tmp/run-async-2.2.0.tgz_1458198577245_0.4591540393885225" }, "directories": {} }, "2.3.0": { "name": "run-async", "version": "2.3.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "engines": { "node": ">=0.12.0" }, "repository": { "type": "git", "url": "git+https://github.com/sboudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "files": [ "index.js" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "dependencies": { "is-promise": "^2.1.0" }, "devDependencies": { "mocha": "^3.1.2" }, "gitHead": "23767c9d7eaf6a6bb1241fc9e12776685258c50e", "bugs": { "url": "https://github.com/sboudrias/run-async/issues" }, "homepage": "https://github.com/sboudrias/run-async#readme", "_id": "run-async@2.3.0", "_shasum": "0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0", "_from": ".", "_npmVersion": "3.10.8", "_nodeVersion": "7.0.0", "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "dist": { "shasum": "0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/run-async-2.3.0.tgz_1480655904296_0.6874290609266609" }, "directories": {} }, "2.4.0": { "name": "run-async", "version": "2.4.0", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "engines": { "node": ">=0.12.0" }, "repository": { "type": "git", "url": "git+https://github.com/SBoudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "dependencies": { "is-promise": "^2.1.0" }, "devDependencies": { "mocha": "^7.1.0" }, "gitHead": "6dc42ae3c416e4c4feb9069720f4e7c7796c4e15", "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "homepage": "https://github.com/SBoudrias/run-async#readme", "_id": "run-async@2.4.0", "_nodeVersion": "13.8.0", "_npmVersion": "6.13.7", "dist": { "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==", "shasum": "e59054a5b86876cfae07f431d18cbaddc594f1e8", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz", "fileCount": 4, "unpackedSize": 6537, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVkMfCRA9TVsSAnZWagAAgcgP/j64tRGFdceaywDohPlM\n9O7tnDmW+Ri7QZ33pnDNNw/TOmwC6ScTZhSkbCVUNJehiiR4xhTCdnrWLCuc\nd4+0NreuCbEiqyGtGg3wkO9nZpKp57+OVY1OsQhqrRqsAqGlplFGOOPhya0K\nxtiMtZK3X4ocoAl7CMRNdj9YUg2+iH0USyoUwN2UvySXEkKdxyrlOY8iO9VY\nXBwS6IEs3Iq+1/sh9vStrMdwzKPCWZ3StybSMHx4D5SUe0/oYdl+h3xPzls8\nGP24kmX5Wm4htw+NUDtjjnuxIJMe+8c5lEqxdlW0Es1siJUZzb13uTmmh/OG\nAICBlIg6I+JppneP/V0GgxR64HMfGnGEwBcTJiOz7DCR5/jO6TC9HVxm1rE+\nU5qzrKXSmOnsnkzGCJcubN/Dnbe9ALDVoKO0NGSMpJjcm7jszAbimCpIHSeI\nj/MsxV6hjT4ddjcY+TSX7GLI5Ve3pRdc8uxleij9HVnf7sbG3YL9uJMGOLFB\n3lSFVx1V+6M9+wNGl4l4zOKMwMdWiTZkpqM+PvCDHGLpjv1bP7Q0ufSkjkr8\nDv/kau5hlRnIfUQEfSBYUNqI66pzmiu5l9tT0d+xKCPtTed3Cm3HDvIQpxbm\n+Mk9pbb7D86SYQPPzOR0Ji1q4ihvjz4gpu0u3lEc3N1Av/ighPY4IsY/uEPc\nnIJ4\r\n=ryfi\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "directories": {}, "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/run-async_2.4.0_1582711582706_0.5107281545660194" }, "_hasShrinkwrap": false }, "2.4.1": { "name": "run-async", "version": "2.4.1", "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", "main": "index.js", "scripts": { "test": "mocha -R spec" }, "engines": { "node": ">=0.12.0" }, "repository": { "type": "git", "url": "git+https://github.com/SBoudrias/run-async.git" }, "keywords": [ "flow", "flow-control", "async" ], "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "license": "MIT", "dependencies": {}, "devDependencies": { "mocha": "^7.1.0" }, "gitHead": "f3e0a18abf6e9569abfcf327daa9351c95f109b1", "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "homepage": "https://github.com/SBoudrias/run-async#readme", "_id": "run-async@2.4.1", "_nodeVersion": "12.16.1", "_npmVersion": "6.13.4", "dist": { "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", "shasum": "8440eccf99ea3e70bd409d49aab88e10c189a455", "tarball": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", "fileCount": 4, "unpackedSize": 6604, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepnA5CRA9TVsSAnZWagAAWkUP/ioFe+TOHso6jPzihreo\nMoQTLB0+I4coYc642azZ1t306nHsj8m5Ts4JZiWaiTOq3HGY58yzNDINWi06\nsG1hIRL5f1D323sq6d+Ec5H/81qCDGNXFTzDKAVPLdsQCnHiTfcmYgv2C8UD\nDPR3gmTujpONC5S1iIhGXZAcEJFYNVnep6KPs/7UNMxlEP/bnMaWh2oLQg/Q\nllZFcBWh/mGnqO/6o9JshJsO2n6paFb5kuPsc36Atioqiix4QCRn9KG7rEty\n02JXaTOUAmqXeKnEsnKYwK77h2I6mkDrgNz29rDqzJmVmTxFqbGbuxU980Yb\nd4IU+4X/w6USQRjhT6IzRsfwe2EQpJ+39BZblYBlogwt7137DyOzXAAjWaVr\n6x6EeisqUViwmmw4JJn9jspI67GcQD6eE07NYydWNVKGMA5rRl0kaS7f6m6d\ntZlBUggMn3SKMZQmeTiXSK7OukwMlPKURv8G1DpBgYbtdK1ZF9s3Y4o54T+y\nQRzW6na4sKWueC90iBq6a5plYRFOhUMHkvng8YD/8bdG9GMv/ooWkWJOwjbK\n0lGZd4WvDkFGxXA+ASxQUY+rkNhm1nyX6a1UnhiOXJMcvIs3v53mbPwn5UmD\n+2kUIA04LY8OM1p6Pg7p8xp2vUrbuN+r8vwgGrO5pJoYk8plyNBivJr8WYGv\n6AAa\r\n=F96P\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "_npmUser": { "name": "sboudrias", "email": "admin@simonboudrias.com" }, "directories": {}, "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/run-async_2.4.1_1587966009268_0.1932416029427002" }, "_hasShrinkwrap": false } }, "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", "maintainers": [ { "name": "sboudrias", "email": "admin@simonboudrias.com" } ], "time": { "modified": "2020-04-27T05:40:11.770Z", "created": "2014-08-11T01:11:31.399Z", "0.1.0": "2014-08-11T01:11:31.399Z", "1.0.0": "2015-10-13T06:10:24.777Z", "2.0.0": "2015-10-18T21:12:16.901Z", "2.1.0": "2016-01-14T06:51:30.979Z", "2.2.0": "2016-03-17T07:09:37.775Z", "2.3.0": "2016-12-02T05:18:24.544Z", "2.4.0": "2020-02-26T10:06:22.816Z", "2.4.1": "2020-04-27T05:40:09.368Z" }, "homepage": "https://github.com/SBoudrias/run-async#readme", "keywords": [ "flow", "flow-control", "async" ], "repository": { "type": "git", "url": "git+https://github.com/SBoudrias/run-async.git" }, "author": { "name": "Simon Boudrias", "email": "admin@simonboudrias.com" }, "bugs": { "url": "https://github.com/SBoudrias/run-async/issues" }, "license": "MIT", "readmeFilename": "README.md", "users": { "itonyyo": true, "71emj1": true } }