/** * Applies the specified partial function to each entry of the map, filtering * out `None` values. * * @tsplus static ImmutableMap.Aspects filterMapWithIndex * @tsplus pipeable ImmutableMap filterMapWithIndex */ export function filterMapWithIndex(pf: (key: K, value: V) => Maybe) { return (self: ImmutableMap): ImmutableMap => { const map = new Map() for (const [key, value] of self.internalMap) { const result = pf(key, value) if (result.isSome()) { map.set(key, result.value) } } return new ImmutableMap(map) } }