blob: b2d9405e6b29c41a53d860030f0c84a9e2712c0e [file] [log] [blame]
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _assertPromise = /*#__PURE__*/require('./internal/_assertPromise');
/**
* Returns the result of applying the onSuccess function to the value inside
* a successfully resolved promise. This is useful for working with promises
* inside function compositions.
*
* @func
* @memberOf R
* @category Function
* @sig (a -> b) -> (Promise e a) -> (Promise e b)
* @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b)
* @param {Function} onSuccess The function to apply. Can return a value or a promise of a value.
* @param {Promise} p
* @return {Promise} The result of calling `p.then(onSuccess)`
* @see R.otherwise
* @example
*
* var makeQuery = (email) => ({ query: { email }});
*
* //getMemberName :: String -> Promise ({firstName, lastName})
* var getMemberName = R.pipe(
* makeQuery,
* fetchMember,
* R.then(R.pick(['firstName', 'lastName']))
* );
*/
var then = /*#__PURE__*/_curry2(function then(f, p) {
_assertPromise('then', p);
return p.then(f);
});
module.exports = then;