swc/bundler/tests/.cache/deno/a288ff294ba8ed53e4c4efda5e662ffc01756ece.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

45 lines
1.3 KiB
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/sequence.js
import _curry2 from './internal/_curry2.js';
import ap from './ap.js';
import map from './map.js';
import prepend from './prepend.js';
import reduceRight from './reduceRight.js';
/**
* Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable)
* of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an
* Applicative of Traversable.
*
* Dispatches to the `sequence` method of the second argument, if present.
*
* @func
* @memberOf R
* @since v0.19.0
* @category List
* @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a)
* @param {Function} of
* @param {*} traversable
* @return {*}
* @see R.traverse
* @example
*
* R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3])
* R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing()
*
* R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)]
* R.sequence(R.of, Nothing()); //=> [Nothing()]
*/
var sequence = _curry2(function sequence(of, traversable) {
return typeof traversable.sequence === 'function' ?
traversable.sequence(of) :
reduceRight(
function(x, acc) { return ap(map(prepend, x), acc); },
of([]),
traversable
);
});
export default sequence;