Skip to content

Commit cb24001

Browse files
committed
Avoid unnecessary loop in Promise.denodeify
1 parent 3184374 commit cb24001

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/node-extensions.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ Promise.denodeify = function (fn, argumentCount) {
1414
argumentCount = argumentCount || Infinity;
1515
return function () {
1616
var self = this;
17-
var args = Array.prototype.slice.call(arguments);
17+
var args = Array.prototype.slice.call(arguments, 0,
18+
argumentCount > 0 ? argumentCount : 0);
1819
return new Promise(function (resolve, reject) {
19-
while (args.length && args.length > argumentCount) {
20-
args.pop();
21-
}
2220
args.push(function (err, res) {
2321
if (err) reject(err);
2422
else resolve(res);

0 commit comments

Comments
 (0)