libs/removeDeepFromMap.js
function removeDeepFromMap(map, key) {
  const newMap = new Map();

  for (const [aKey, val] of map) {
    if (aKey !== key && val instanceof Map) {
      newMap.set(aKey, removeDeepFromMap(val, key));
    } else if (aKey !== key) {
      newMap.set(aKey, val);
    }
  }

  return newMap;
}
function removeDeepFromMap(map, key) {
  const newMap = new Map();

  for (const [aKey, val] of map) {
    if (aKey !== key && val instanceof Map) {
      newMap.set(aKey, removeDeepFromMap(val, key));
    } else if (aKey !== key) {
      newMap.set(aKey, val);
    }
  }

  return newMap;
}
function removeDeepFromMap ( map , key ) { const newMap = new Map ( ) ; for ( const [ aKey , val ] of map ) { if ( aKey !== key && val instanceof Map ) { newMap . set ( aKey , removeDeepFromMap ( val , key ) ) ; } else if ( aKey !== key ) { newMap . set ( aKey , val ) ; } } return newMap ; }
Removes a key and all of its references from a map.
This function has no side-effects as it returns
a brand new map.

@param {Map}     map - Map to remove the key from
@param {string}  key - Key to remove from the map
@return {Map}    New map without the passed key
Removes a key and all of its references from a map . This function has no side - effects as it returns a brand new map .