UNPKG

tuna-jslinq

Version:

Linq methods for JavaScript/TypeScript for working with Arrays

12 lines (10 loc) 358 B
JSLinqHelper.NonEnumerable("TakeWhile", function <T>(this: T[], selector: (item: T, index: number) => boolean): T[] { const result = []; const length = this.length; let i = 0; while (i < length && selector(this[i], i) === true) { result.push(this[i++]); } return result; });