libs/validateDeep.js
function validateDeep(map) {
  if (!(map instanceof Map)) {
    throw new Error(`Invalid graph: Expected Map instead found ${typeof map}`);
  }

  map.forEach((value, key) => {
    if (typeof value === 'object' && value instanceof Map) {
      validateDeep(value);
      return;
    }

    if (typeof value !== 'number' || value <= 0) {
      throw new Error(`Values must be numbers greater than 0. Found value ${value} at ${key}`);
    }
  });
}
function validateDeep(map) {
  if (!(map instanceof Map)) {
    throw new Error(`Invalid graph: Expected Map instead found ${typeof map}`);
  }

  map.forEach((value, key) => {
    if (typeof value === 'object' && value instanceof Map) {
      validateDeep(value);
      return;
    }

    if (typeof value !== 'number' || value <= 0) {
      throw new Error(`Values must be numbers greater than 0. Found value ${value} at ${key}`);
    }
  });
}
function validateDeep ( map ) { if ( ! ( map instanceof Map ) ) { throw new Error ( ` ${ typeof map } ` ) ; } map . forEach ( ( value , key ) => { if ( typeof value === 'object' && value instanceof Map ) { validateDeep ( value ) ; return ; } if ( typeof value !== 'number' || value <= 0 ) { throw new Error ( ` ${ value } ${ key } ` ) ; } } ) ; }
Validate a map to ensure all it's values are either a number or a map

@param {Map} map - Map to valiadte
Validate a map to ensure all it s values are either a number or a map