Socket
Socket
Sign inDemoInstall

async-manager-promise

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

23

build/index.js
import AsyncManager from 'async-manager';
const errCbToPromiseExecutor = (resolve, reject) => (err, data) => {
if (err) {
reject(err);
}
else {
resolve(data);
}
};
class AsyncManagerPromise {

@@ -8,10 +16,4 @@ constructor() {

const promise = new Promise(async (resolve, reject) => {
this.manager.add(id, (err, data) => {
if (err) {
reject(err);
}
else {
resolve(data);
}
});
const cb = errCbToPromiseExecutor(resolve, reject);
this.manager.add(id, cb);
});

@@ -21,4 +23,5 @@ return promise;

getPromiseWithId(onInit) {
const promise = new Promise(async (resolve) => {
const id = this.manager.addAndGetId(resolve);
const promise = new Promise(async (resolve, reject) => {
const cb = errCbToPromiseExecutor(resolve, reject);
const id = this.manager.addAndGetId(cb);
if (onInit) {

@@ -25,0 +28,0 @@ onInit(id);

{
"name": "async-manager-promise",
"version": "0.0.4",
"version": "0.0.5",
"description": "TODO",

@@ -5,0 +5,0 @@ "main": "./build/index.js",

import AsyncManager from 'async-manager'
const errCbToPromiseExecutor = (resolve, reject) =>
(err, data) => {
if (err) {
reject(err)
} else {
resolve(data)
}
}
class AsyncManagerPromise<OutputType, Id = any> {

@@ -8,9 +17,4 @@ protected manager = new AsyncManager<OutputType, Id>()

const promise = new Promise<OutputType>(async (resolve, reject) => {
this.manager.add(id, (err, data) => {
if (err) {
reject(err)
} else {
resolve(data)
}
})
const cb = errCbToPromiseExecutor(resolve, reject)
this.manager.add(id, cb)
})

@@ -22,4 +26,6 @@

getPromiseWithId(onInit?: (id: string) => void) {
const promise = new Promise<OutputType>(async (resolve) => {
const id = this.manager.addAndGetId(resolve)
const promise = new Promise<OutputType>(async (resolve, reject) => {
const cb = errCbToPromiseExecutor(resolve, reject)
const id = this.manager.addAndGetId(cb)
if (onInit) {

@@ -26,0 +32,0 @@ onInit(id)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc