| var _curry2 = | |
| /*#__PURE__*/ | |
| require("./internal/_curry2"); | |
| var ap = | |
| /*#__PURE__*/ | |
| require("./ap"); | |
| var map = | |
| /*#__PURE__*/ | |
| require("./map"); | |
| var prepend = | |
| /*#__PURE__*/ | |
| require("./prepend"); | |
| var reduceRight = | |
| /*#__PURE__*/ | |
| require("./reduceRight"); | |
| /** | |
| * 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 = | |
| /*#__PURE__*/ | |
| _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); | |
| }); | |
| module.exports = sequence; |