Select Git revision
defaultMap.js
Forked from
SOFT Core / SOFT 260 / Boost Board Game
5 commits behind, 1 commit ahead of the upstream repository.
-
Brady James Garvin authoredBrady James Garvin authored
defaultMap.js 305 B
export default class DefaultMap extends Map {
constructor(obtainDefault) {
super();
this.obtainDefault = obtainDefault;
}
get(key) {
if (super.has(key)) {
return super.get(key);
}
const result = this.obtainDefault(key);
this.set(key, result);
return result;
}
}