/** * Applies the specified predicate to each entry of the map, filitering out any * values that do not satisfy the predicate. * * @tsplus static ImmutableMap.Aspects filterWithIndex * @tsplus pipeable ImmutableMap filterWithIndex */ export function filterWithIndex( f: (key: K, value: V) => value is B ): (self: ImmutableMap) => ImmutableMap export function filterWithIndex( f: (key: K, value: V) => boolean ): (self: ImmutableMap) => ImmutableMap export function filterWithIndex(f: (key: K, value: V) => boolean) { return (self: ImmutableMap): ImmutableMap => { const map = new Map() for (const [key, value] of self.internalMap) { if (f(key, value)) { map.set(key, value) } } return new ImmutableMap(map) } }