diff --git a/CHANGELOG.md b/CHANGELOG.md index b314b98..56cbe1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.2.0 + +- `Promise.promisify` now uses `coroutine.wrap` instead of `Promise.spawn` + # 2.1.0 - Add `finallyCall`, `andThenCall` diff --git a/lib/README.md b/lib/README.md index 4adf8c1..1cc638b 100644 --- a/lib/README.md +++ b/lib/README.md @@ -146,9 +146,6 @@ docs: type: kind: function params: "...: ...any?" - - name: selfValue - type: any? - desc: This value will be prepended to the arguments list given to the curried function. This can be used to lock a method to a single instance. Otherwise, you can pass the self value before the argument list. returns: - desc: The function acts like the passed function but now returns a Promise of its return values. type: diff --git a/lib/init.lua b/lib/init.lua index 825ee3a..a8ca86e 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -335,15 +335,11 @@ end --[[ Converts a yielding function into a Promise-returning one. ]] -function Promise.promisify(callback, selfValue) +function Promise.promisify(callback) return function(...) local length, values = pack(...) return Promise.new(function(resolve) - if selfValue == nil then - resolve(callback(unpack(values, 1, length))) - else - resolve(callback(selfValue, unpack(values, 1, length))) - end + resolve(coroutine.wrap(callback)(unpack(values, 1, length))) end) end end