Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
simplify util.promisify. thanks @vweever!
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Aug 26, 2017
1 parent fed3a2d commit c74e608
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ function isDefined (v) {
}

function promisify () {
var resolve_, reject_
var callback
var promise = new Promise(function (resolve, reject) {
[resolve_, reject_] = [resolve, reject]
callback = function callback (err, value) {
if (err) reject(err)
else resolve(value)
}
})
function callback (err, value) {
if (err) reject_(err)
else resolve_(value)
}
return [ callback, promise ]
}

Expand Down

0 comments on commit c74e608

Please sign in to comment.