import { Iterable } from 'ix'; export function asIterable(this: T[]): Iterable { return Iterable.from(this); } export function filterNull( this: Array, callbackfn?: ( value: T, index: number, array: Array, ) => boolean, ): T[] { return (this as T[]).filter((x, i, a) => { if (x == null) { return false; } return callbackfn == null ? true : callbackfn(x, i, a); }); } declare global { interface Array { asIterable: typeof asIterable; filterNull: typeof filterNull; } } Array.prototype.asIterable = asIterable; Array.prototype.filterNull = filterNull;