mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
11 lines
221 B
TypeScript
11 lines
221 B
TypeScript
export function firstIndex<T>(array: readonly T[], fn: (t: T) => boolean): number {
|
|
for (let i = 0; i < array.length; i++) {
|
|
if (fn(array[i])) {
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
export const UTF8 = 'utf8'; |