prominator
Table of Contents
- catchIf(predicate, fn) - catch an error if a condition is met
- expect(...modifiers, predicate) - expect a condition to be met
- expectCatch(err) - expect an error to be caught
- Prominator.lift(fn, [instance]) - convert a node-style function to a promise
- rethrow(err) - re-throw an error
catchIf(predicate, fn)
Catches an error and invokes fn if predicate returns a truthy value. If a falsy value is returned, the error will be re-thrown and the fn is not invoked.
const Prominator = ;{return {return o instanceof Type;};}Prominator; // => SyntaxErrorProminator// => SyntaxError;
expect(...modifiers, predicate)
Expects that a condition is met. The resolved value of the promise is modified using the modifiers and then passed to a predicate. If the predicate returns a truthy value, then the resolved value of the promise is returned. If the predicate returns a falsy value, then the promise is rejected.
const Prominator = ;{return n & 1;}{return {return m + n;};}Prominator; // => 3Prominator; // => AssertionErrorProminator; // => 6Prominator; // => AssertionError
expectCatch(err)
Returns a new promise that resolves if err is caught. If no errors are caught or the error is not equal to err, then the promise is rejected.
const Prominator = ;Prominator; // => ExpectedPromiseRejectionErrorProminator; // => AssertionErrorProminator; // => undefined
Prominator.lift(fn, [instance])
Converts the node-style function fn to a promise. If an instance is provided, it will be bound as the this parameter for the function.
const Prominator = ;{;}const add3 = Prominator;; // => 7
rethrow(err)
Catches an error and throws err in its place.
const Prominator = ;Prominator; // => barProminator; // => foo