mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-23 01:13:48 +01:00
Use takeWhile instead of some (#3475)
This commit is contained in:
parent
865695c7a4
commit
6e4fa18b7f
File diff suppressed because one or more lines are too long
@ -57,3 +57,15 @@ export function lessThan(xs: number[], ys: number[]): boolean {
|
|||||||
}
|
}
|
||||||
return xs.length < ys.length;
|
return xs.length < ys.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function takeWhile<T>(f: (x: T) => boolean, xs: T[]): T[] {
|
||||||
|
const ys = [];
|
||||||
|
for (const x of xs) {
|
||||||
|
if (f(x)) {
|
||||||
|
ys.push(x);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ys;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user