You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_MapCache.js 869B

1234567891011121314151617181920212223242526272829303132
  1. var mapCacheClear = require('./_mapCacheClear'),
  2. mapCacheDelete = require('./_mapCacheDelete'),
  3. mapCacheGet = require('./_mapCacheGet'),
  4. mapCacheHas = require('./_mapCacheHas'),
  5. mapCacheSet = require('./_mapCacheSet');
  6. /**
  7. * Creates a map cache object to store key-value pairs.
  8. *
  9. * @private
  10. * @constructor
  11. * @param {Array} [entries] The key-value pairs to cache.
  12. */
  13. function MapCache(entries) {
  14. var index = -1,
  15. length = entries == null ? 0 : entries.length;
  16. this.clear();
  17. while (++index < length) {
  18. var entry = entries[index];
  19. this.set(entry[0], entry[1]);
  20. }
  21. }
  22. // Add methods to `MapCache`.
  23. MapCache.prototype.clear = mapCacheClear;
  24. MapCache.prototype['delete'] = mapCacheDelete;
  25. MapCache.prototype.get = mapCacheGet;
  26. MapCache.prototype.has = mapCacheHas;
  27. MapCache.prototype.set = mapCacheSet;
  28. module.exports = MapCache;