Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

executable file 20 lines (13 sloc) 411 Bytes
import { push } from './push';
type FilterCallback<T> = (value: T, index: number, array: T[]) => boolean;
export function filter<T>(array: T[], callback: FilterCallback<T>) {
const result = [];
const { length } = array;
for (let index = 0; index < length; index += 1) {
const value = array[index];
if (callback(value, index, array)) {
push(result, value);
}
}
return result;
}
You can’t perform that action at this time.