mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/andThen.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
import _assertPromise from './internal/_assertPromise.js';
|
|
|
|
|
|
/**
|
|
* 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
|
|
* @since v0.27.1
|
|
* @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
|
|
*
|
|
* const makeQuery = email => ({ query: { email }});
|
|
* const fetchMember = request =>
|
|
* Promise.resolve({ firstName: 'Bob', lastName: 'Loblaw', id: 42 });
|
|
*
|
|
* //getMemberName :: String -> Promise ({ firstName, lastName })
|
|
* const getMemberName = R.pipe(
|
|
* makeQuery,
|
|
* fetchMember,
|
|
* R.andThen(R.pick(['firstName', 'lastName']))
|
|
* );
|
|
*
|
|
* getMemberName('bob@gmail.com').then(console.log);
|
|
*/
|
|
var andThen = _curry2(function andThen(f, p) {
|
|
_assertPromise('andThen', p);
|
|
|
|
return p.then(f);
|
|
});
|
|
export default andThen;
|