@protobufjs/aspromise
Advanced tools
Comparing version 1.0.2 to 1.0.3
21
index.js
@@ -16,14 +16,15 @@ "use strict"; | ||
params.push(arguments[i++]); | ||
var pending = true; | ||
return new Promise(function asPromiseExecutor(resolve, reject) { | ||
params.push(function asPromiseCallback(err/*, varargs */) { | ||
if (err) { | ||
if (reject) { | ||
if (pending) { | ||
pending = false; | ||
if (err) | ||
reject(err); | ||
reject = null; | ||
else { | ||
var args = []; | ||
for (var i = 1; i < arguments.length;) | ||
args.push(arguments[i++]); | ||
resolve.apply(null, args); | ||
} | ||
} else { | ||
var args = []; | ||
for (var j = 1; j < arguments.length;) | ||
args.push(arguments[j++]); | ||
resolve.apply(null, args); | ||
} | ||
@@ -34,5 +35,5 @@ }); | ||
} catch (err) { | ||
if (reject) { | ||
if (pending) { | ||
pending = false; | ||
reject(err); | ||
reject = null; | ||
} | ||
@@ -39,0 +40,0 @@ } |
{ | ||
"name": "@protobufjs/aspromise", | ||
"description": "Returns a promise from a node-style callback function.", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>", | ||
@@ -6,0 +6,0 @@ "repository": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
13634
39
1