mavend/octoboard

View on GitHub
src/utils/mapWithDefault.js

Summary

Maintainability
A
0 mins
Test Coverage
D
60%
export default class MapWithDefault extends Map {
  get(key) {
    if (!this.has(key)) return this.default(key);
    return super.get(key);
  }

  constructor(entries, defaultFunction = () => null) {
    super(entries);
    this.default = defaultFunction;
  }
}