| [a762898] | 1 | import { ListIteratee } from '../_internal/ListIteratee.js';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Creates a slice of array with elements taken from the beginning. Elements are taken until predicate
|
|---|
| 5 | * returns falsey. The predicate is invoked with three arguments: (value, index, array).
|
|---|
| 6 | *
|
|---|
| 7 | * @template T
|
|---|
| 8 | * @param {ArrayLike<T> | null | undefined} array - The array to query.
|
|---|
| 9 | * @param {ListIteratee<T>} [predicate] - The function invoked per iteration.
|
|---|
| 10 | * @returns {T[]} Returns the slice of array.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const users = [
|
|---|
| 14 | * { 'user': 'barney', 'active': false },
|
|---|
| 15 | * { 'user': 'fred', 'active': false },
|
|---|
| 16 | * { 'user': 'pebbles', 'active': true }
|
|---|
| 17 | * ];
|
|---|
| 18 | *
|
|---|
| 19 | * takeWhile(users, function(o) { return !o.active; });
|
|---|
| 20 | * // => objects for ['barney', 'fred']
|
|---|
| 21 | *
|
|---|
| 22 | * @example
|
|---|
| 23 | * takeWhile(users, { 'user': 'barney', 'active': false });
|
|---|
| 24 | * // => objects for ['barney']
|
|---|
| 25 | *
|
|---|
| 26 | * @example
|
|---|
| 27 | * takeWhile(users, ['active', false]);
|
|---|
| 28 | * // => objects for ['barney', 'fred']
|
|---|
| 29 | *
|
|---|
| 30 | * @example
|
|---|
| 31 | * takeWhile(users, 'active');
|
|---|
| 32 | * // => []
|
|---|
| 33 | */
|
|---|
| 34 | declare function takeWhile<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIteratee<T>): T[];
|
|---|
| 35 |
|
|---|
| 36 | export { takeWhile };
|
|---|