UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

14 lines (12 loc) 300 B
function takeWhile(arr, shouldContinueTaking) { const result = []; for (let i = 0; i < arr.length; i++) { const item = arr[i]; if (!shouldContinueTaking(item, i, arr)) { break; } result.push(item); } return result; } export { takeWhile };