Rejects a promise that fails a test condition
var condition = ;var rejectAbove400 = ; { return ;} { return ;} ; ;
Composition
As promise-condition
input and output is a function returning a promise, you can compose them easily with other similar helpers (see below).
In the example below, our /data
API is a bit janky and might return HTTP 500 errors. We'll retry them twice before giving up.
var promiseRetry = ;var promiseCondition = ; var retryTwice = ;var rejectAbove500 = ; { // this call might return 500 sometimes return ;} ;
See also
promise-condition
composes really well with the following promise helper: