All files / ima/storage MapStorage.js

100% Statements 16/16
100% Branches 0/0
100% Functions 10/10
100% Lines 16/16
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91      8x               6x             75x               75x             9x             43x             45x             178x 178x             15x 15x             59x 59x             33x             2x       8x  
import ns from '../namespace';
import Storage from './Storage';
 
ns.namespace('ima.storage');
 
/**
 * Implementation of the {@codelink Storage} interface that relies on the
 * native {@code Map} for storage.
 */
export default class MapStorage extends Storage {
  static get $dependencies() {
    return [];
  }
 
  /**
	 * Initializes the map storage.
	 */
  constructor() {
    super();
 
    /**
		 * The internal storage of entries.
		 *
		 * @protected
		 * @type {Map<string, *>}
		 */
    this._storage = new Map();
  }
 
  /**
	 * @inheritdoc
	 */
  init() {
    return this;
  }
 
  /**
	 * @inheritdoc
	 */
  has(key) {
    return this._storage.has(key);
  }
 
  /**
	 * @inheritdoc
	 */
  get(key) {
    return this._storage.get(key);
  }
 
  /**
	 * @inheritdoc
	 */
  set(key, value) {
    this._storage.set(key, value);
    return this;
  }
 
  /**
	 * @inheritdoc
	 */
  delete(key) {
    this._storage.delete(key);
    return this;
  }
 
  /**
	 * @inheritdoc
	 */
  clear() {
    this._storage.clear();
    return this;
  }
 
  /**
	 * @inheritdoc
	 */
  keys() {
    return this._storage.keys();
  }
 
  /**
	 * @override
	 */
  size() {
    return this._storage.size;
  }
}
 
ns.ima.storage.MapStorage = MapStorage;