import { PrimaryKeyType } from "../glossary" ; export function forEach < K extends PrimaryKeyType , V > ( fn , map ) { for ( const [ key , value ] of map . entries ( ) ) { fn ( key , value ) ; } } export function filter < K extends PrimaryKeyType , V > ( predicate , map ) { const nextMap = new Map < K , V > ( ) ; forEach ( ( key , value ) => { if ( predicate ( key , value ) ) { nextMap . set ( key , value ) ; } } , map ) ; return nextMap ; }