apr-asyncify
Advanced tools
+31
| <!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
| ## asyncify | ||
| <a id="asyncify"></a> | ||
| Take a sync function and make it async. This is useful for plugging sync functions into a [`waterfall`](#waterfall), [`series`](#series), or other async functions. | ||
| [](https://www.npmjs.com/package/apr-asyncify) [](https://www.npmjs.com/package/apr-asyncify) | ||
| **Parameters** | ||
| - `function` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** | ||
| **Examples** | ||
| ```javascript | ||
| import awaitify from 'apr-awaitify'; | ||
| import asyncify from 'apr-asyncify'; | ||
| import waterfall from 'apr-waterfall'; | ||
| import apply from 'apr-apply'; | ||
| const readFile = awaitify(require('fs').readFile); | ||
| const pkgPath = path.join(__dirname, './package.json'); | ||
| const pkg = await waterfall([ | ||
| apply(readFile, pkgPath, 'utf8'), | ||
| asyncify(JSON.parse) | ||
| ]); | ||
| ``` | ||
| Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** |
+25
-0
@@ -0,1 +1,26 @@ | ||
| /** | ||
| * <a id="asyncify"></a> | ||
| * Take a sync function and make it async. This is useful for plugging sync functions into a [`waterfall`](#waterfall), [`series`](#series), or other async functions. | ||
| * | ||
| * [](https://www.npmjs.com/package/apr-asyncify) [](https://www.npmjs.com/package/apr-asyncify) | ||
| * | ||
| * @kind function | ||
| * @name asyncify | ||
| * @param {Function} function | ||
| * @returns {Function} | ||
| * | ||
| * @example | ||
| * import awaitify from 'apr-awaitify'; | ||
| * import asyncify from 'apr-asyncify'; | ||
| * import waterfall from 'apr-waterfall'; | ||
| * import apply from 'apr-apply'; | ||
| * | ||
| * const readFile = awaitify(require('fs').readFile); | ||
| * const pkgPath = path.join(__dirname, './package.json'); | ||
| * | ||
| * const pkg = await waterfall([ | ||
| * apply(readFile, pkgPath, 'utf8'), | ||
| * asyncify(JSON.parse) | ||
| * ]); | ||
| */ | ||
| module.exports = (fn) => { | ||
@@ -2,0 +27,0 @@ return (...args) => { |
+1
-1
| { | ||
| "name": "apr-asyncify", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "homepage": "https://github.com/ramitos/apr/tree/master/packages/asyncify", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
2586
408.06%3
50%36
227.27%1
-50%32
Infinity%2
100%