Takes elements from the source while the predicate returns true.
true
Type of items in the source.
Predicate function to determine if an element should be taken.
Operation that takes elements from the source while the predicate returns true.
const result = takeWhile<number>((x) => x < 3)([1, 2, 3, 4]);console.log([...result]); // [1, 2] Copy
const result = takeWhile<number>((x) => x < 3)([1, 2, 3, 4]);console.log([...result]); // [1, 2]
Takes elements from the source while the predicate returns
true
.