All files / src/domain/ErrorMessage index.js

30% Statements 3/10
16.67% Branches 1/6
33.33% Functions 1/3
30% Lines 3/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33    1x         1x 1x                                                
import is from 'is_js';
 
let set = false;
let map;
 
class ErrorMessage {
  static for(key) {
    Eif (is.not.object(map)) {
      return undefined;
    }
 
    return map[key];
  }
 
  static getMap() {
    return map;
  }
 
  static setMap(newMap) {
    if (set !== false) {
      throw new Error('ErrorMessage map has already been set!');
    }
 
    set = true;
 
    if (is.object(newMap)) {
      map = Object.freeze(Object.assign({}, newMap));
    }
  }
}
 
export default ErrorMessage;