Update promisify.md

This commit is contained in:
Angelos Chalaris
2017-12-13 12:39:24 +02:00
committed by GitHub
parent f8ee54604b
commit 1a0d41d2b8

View File

@ -8,9 +8,7 @@ const promisify = func =>
(...args) => (...args) =>
new Promise((resolve, reject) => new Promise((resolve, reject) =>
func(...args, (err, result) => func(...args, (err, result) =>
err err ? reject(err) : resolve(result));
? reject(err)
: resolve(result))
) )
// const stat = promisify(fs.stat) // const stat = promisify(fs.stat)
// stat('foo.txt') -> Promise resolves if `foo.txt` exists, otherwise rejects // stat('foo.txt') -> Promise resolves if `foo.txt` exists, otherwise rejects