Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-asyncify

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-asyncify - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

ex.js

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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc