1 | /** @license MIT License (c) copyright B Cavalier & J Hann */
|
2 |
|
3 | (function(define) {
|
4 | define(function(require) {
|
5 |
|
6 | var unfold = require('../when').unfold;
|
7 |
|
8 | /**
|
9 | * @deprecated
|
10 | * Given a seed and generator, produces an Array. Effectively the
|
11 | * dual (opposite) of when.reduce()
|
12 | * @param {function} generator function that generates a value (or promise
|
13 | * for a value) to be placed in the resulting array
|
14 | * @param {function} condition given a seed, must return truthy if the unfold
|
15 | * should continue, or falsey if it should terminate
|
16 | * @param {*|Promise} seed any value or promise
|
17 | * @return {Promise} resulting array
|
18 | */
|
19 | return function list(generator, condition, seed) {
|
20 | var result = [];
|
21 |
|
22 | return unfold(generator, condition, append, seed)['yield'](result);
|
23 |
|
24 | function append(value, newSeed) {
|
25 | result.push(value);
|
26 | return newSeed;
|
27 | }
|
28 | };
|
29 |
|
30 | });
|
31 | })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
|
32 |
|