forked from mirror/misskey
Use takeWhile instead of some (#3475)
This commit is contained in:
parent
184eb00133
commit
928d359dd2
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