Skip to content

Commit 23fd51d

Browse files
committed
Implement promises.nfcall() without bluebird
1 parent 00d20d9 commit 23fd51d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/promises.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ exports.toExternalPromise = toExternalPromise;
1111

1212
exports.nfcall = function(func) {
1313
var args = Array.prototype.slice.call(arguments, 1);
14-
var promisedFunc = bluebird.promisify(func);
15-
return promisedFunc.apply(null, args);
14+
15+
return new Promise(function(resolve, reject) {
16+
args.push(function(error, value) {
17+
if (error) {
18+
reject(error);
19+
} else {
20+
resolve(value);
21+
}
22+
});
23+
func.apply(null, args);
24+
});
1625
};
1726

1827
function props(obj) {

0 commit comments

Comments
 (0)