array-asyncify
Advanced tools
Comparing version 0.0.4 to 0.0.5
33
index.js
@@ -46,26 +46,6 @@ const util = require("util") | ||
class Asyncify extends Promise { | ||
class Asyncify { | ||
constructor(array) { | ||
console.log("create promise") | ||
let callback = (res, rej) => { | ||
setTimeout(async () => { | ||
console.log("try resolve") | ||
try { | ||
let ret = await this.apply_() | ||
res(ret) | ||
} catch (e) { | ||
rej(e) | ||
} | ||
}, 0) | ||
// process.nextTick(async () => { | ||
// try { | ||
// let ret = await this.apply_() | ||
// res(ret) | ||
// } catch (e) { | ||
// rej(e) | ||
// } | ||
// }) | ||
} | ||
super(callback) | ||
this.original_ = array | ||
@@ -104,4 +84,3 @@ this.actions_ = [] | ||
} | ||
async apply_() { | ||
return [1, 2, 3] | ||
async apply() { | ||
let array = this.array_; | ||
@@ -129,4 +108,8 @@ for (var i = 0; i < this.actions_.length; i++) { | ||
asyncify(arr) { | ||
return new Asyncify(arr) | ||
let asyncified = new Asyncify(arr) | ||
asyncified.then = function (res, rej) { | ||
asyncified.apply().then(res, rej) | ||
} | ||
return asyncified; | ||
} | ||
} |
{ | ||
"name": "array-asyncify", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Async array functions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,1 @@ | ||
>NOTE | ||
Not work under node 8.x | ||
## Issue | ||
@@ -5,0 +2,0 @@ We cannot use async function graceful in array methods such as `filter`,`map`,`reduce` and so on. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5253
6
162
54