1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 |
|
5 | var _dispatchable =
|
6 | /*#__PURE__*/
|
7 | require("./internal/_dispatchable");
|
8 |
|
9 | var _xdropWhile =
|
10 | /*#__PURE__*/
|
11 | require("./internal/_xdropWhile");
|
12 |
|
13 | var slice =
|
14 | /*#__PURE__*/
|
15 | require("./slice");
|
16 | /**
|
17 | * Returns a new list excluding the leading elements of a given list which
|
18 | * satisfy the supplied predicate function. It passes each value to the supplied
|
19 | * predicate function, skipping elements while the predicate function returns
|
20 | * `true`. The predicate function is applied to one argument: *(value)*.
|
21 | *
|
22 | * Dispatches to the `dropWhile` method of the second argument, if present.
|
23 | *
|
24 | * Acts as a transducer if a transformer is given in list position.
|
25 | *
|
26 | * @func
|
27 | * @memberOf R
|
28 | * @since v0.9.0
|
29 | * @category List
|
30 | * @sig (a -> Boolean) -> [a] -> [a]
|
31 | * @sig (a -> Boolean) -> String -> String
|
32 | * @param {Function} fn The function called per iteration.
|
33 | * @param {Array} xs The collection to iterate over.
|
34 | * @return {Array} A new array.
|
35 | * @see R.takeWhile, R.transduce, R.addIndex
|
36 | * @example
|
37 | *
|
38 | * const lteTwo = x => x <= 2;
|
39 | *
|
40 | * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
|
41 | *
|
42 | * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da'
|
43 | */
|
44 |
|
45 |
|
46 | var dropWhile =
|
47 | /*#__PURE__*/
|
48 | _curry2(
|
49 | /*#__PURE__*/
|
50 | _dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) {
|
51 | var idx = 0;
|
52 | var len = xs.length;
|
53 |
|
54 | while (idx < len && pred(xs[idx])) {
|
55 | idx += 1;
|
56 | }
|
57 |
|
58 | return slice(idx, Infinity, xs);
|
59 | }));
|
60 |
|
61 | module.exports = dropWhile; |
\ | No newline at end of file |