6.0.0 (2022-08-11)
- Update typescript types to use modules instead of export=. (a9cdb29)
- For 99% of users, this should have no effect, but I'll bump the major version just to be safe.
5.0.0 (2019-06-25)
- feat(Drop support for node v6 and node v8.): (187b75d)
- Drop support for node v6 and node v8.
4.1.13 (2018-11-29)
- Fix typescript def for addPromise. (fa4fb38)
4.1.12 (2018-11-29)
- Better typescript definitions. (604b106)
4.1.11 (2018-05-07)
- typescript: Add generic to
addPromise()
. (de41bf2)
- Add typescript support.
- Remove accidental ES6. :)
- Support async/await functions.
- Relaxed rules for
apply()
,call()
, and friends. These used to require a function that took exactlyn
arguments orn+1
arguments (the Promise and the callback cases, respectively). These functions now also accept functions with fewer parameters that return a Promise (possibly the function you're calling into doesn't care about some of the parameters you are passing).
- Correctly handle exceptions from callbacks - convert into uncaught exceptions instead of unhandled rejections.
- Added
callWithCb()
,addPromise()
, andaddCallback()
. - Added
args
parameter tomake()
andbreak()
. - Remove node v4 and v5 from the travis tests, so we can write tests in ES6 syntax.
- Convert tests to javascript, remove dev dependency on coffee-script.
Roll back v4.0.2. If someone passes in a strange function that relies on
arguments
, then we'd throw an error fail in v4.0.0, but we do completely the
wrong thing in v4.0.2.
Relax error conditions for callFn()
and applyFn()
. If a function is passed
that takes too few parameters, we assume it is Promise based.
-
Add
call()
andapply()
. -
Breaking Change - Previously, when using
pb.callFn()
orpb.applyFn()
, if the called function returned a thenable, we would assume the function was Promise based, and would otherwise assume it was callback based. This leads to a dangerous problem if you call a function that returns a scalar, though:let fn = (str) => "hello " + str; pb.callFn(fn, 1, null, "world") .then(result => expect(result).to.equal("hello world"));
Here,
fn.length
is 1, and we're tellingcallFn
we want to call an async function that takes 1 parameter, not including the callback. Iffn
doesn't return a Promise here, the expected behavior would be to wrap the return value in a Promise and return it. In v3.0.0, we would have assumed that sincefn
did not return a Promise, it must be callback based, so we would wait for the callback forever. This is dangerous behavior.In v4.0.0, we now decide whether to treat
fn
as a Promise function or a callback function based onfn.length
. If you callcallFn
orapplyFn
, and tell it you are expecting a function that takes 1 parameter, promise-breaker will now throw an error iffn
does not take 1 or 2 parameters.
- Breaking Change - When using
pb.make(fn)
, iffn
passes more than two arguments to its callback, then these arguments will be transformed into an array and passed to the Promise. Previous versions would only ever return the first value passed to the callback.