normalFunction is applied to the thisArg of the call() invocation:
var sentinel = {};
call.call(sentinel, function() {
assert(this === sentinel); // true
});
normalFunction will be invoked with the other arguments that are passed.
These arguments may also be promises, however instead of invoking
normalFunction with the promises, it'll be invoked with the fulfillment
values. If an argument promise is rejected, the returned promise will be
rejected with the same reason.
normalFunction is applied to the thisArg of the apply() invocation:
var sentinel = {};
apply.call(sentinel, function() {
assert(this === sentinel); // true
});
normalFunction will be invoked with the arguments that are passed in the
args array. args may be a promise, or it can be an array containing
promises, or a promise for such an array. However instead of invoking
normalFunction with the promises, it'll be invoked with the fulfillment
values. If an argument promise is rejected, the returned promise will be
rejected with the same reason.
function foo() {
return 'bar';
}
var promisingFoo = lift(foo);
promisingFoo().then(function(value) {
assert(value === 'bar'); // true
});
The lifted function will return a Promise instance for the result of
normalFunction. This will be rejected with any error thrown by
normalFunction, or resolved with its return value. If a promise or thenable
is returned its state will be adopted.
normalFunction is applied to the thisArg of the listed function's
invocation:
var sentinel = {};
lift(function() {
assert(this === sentinel); // true
}).call(sentinel);
Supports partial application by combining other arguments passed to lift()
with those passed when invoking the lifted function. These arguments may also
be promises, however instead of invoking normalFunction with the promises,
it'll be invoked with the fulfillment values. If an argument promise is
rejected, the returned promise will be rejected with the same reason.
compose(
function() { return 2; },
function(x) { return x * x; }
)().then(function(value) {
assert(value === 4); // true
});
The composed function will return a Promise instance for the (fulfilled)
result of the final func. This will be rejected with any error thrown by
any func, or the rejection reason of any promise or thenable that is
returned. If no funcs are specified, the promise will be fulfilled with
undefined.
Each function is invoked with the thisArg of the composed function's
invocation:
var sentinel = {};
compose(
function() {
assert(this === sentinel); // true
},
function() {
assert(this === sentinel); // true
}
).call(sentinel);
The first func will be invoked with the other arguments that are passed.
These arguments may also be promises, however instead of invoking func with
the promises, it'll be invoked with the fulfillment values. If an argument
promise is rejected, the returned promise will be rejected with the same
reason.
fn
Provides helper methods for functional composition.