MCPcopy Create free account
hub / github.com/krausest/js-framework-benchmark / takeWhile

Function takeWhile

cli/utils/takeWhile.js:13–24  ·  view source on GitHub ↗

* @template T * @param {T[]} array * @param {Predicate } predicate * @returns {T[]}

(array, predicate)

Source from the content-addressed store, hash-verified

11 * @returns {T[]}
12 */
13function takeWhile(array, predicate) {
14 const result = [];
15 for (let i = 0; i < array.length; i++) {
16 const value = array[i];
17 if (predicate(value, i, array)) {
18 result.push(value);
19 } else {
20 break;
21 }
22 }
23 return result;
24}
25
26export { takeWhile };

Callers 1

rebuildAllFrameworksFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected