_ListCache.js 869 B

123456789101112131415161718192021222324252627282930313233
  1. var listCacheClear = require('./_listCacheClear'),
  2. listCacheDelete = require('./_listCacheDelete'),
  3. listCacheGet = require('./_listCacheGet'),
  4. listCacheHas = require('./_listCacheHas'),
  5. listCacheSet = require('./_listCacheSet');
  6. /**
  7. * Creates an list cache object.
  8. *
  9. * @private
  10. * @constructor
  11. * @param {Array} [entries] The key-value pairs to cache.
  12. */
  13. function ListCache(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 `ListCache`.
  23. ListCache.prototype.clear = listCacheClear;
  24. ListCache.prototype['delete'] = listCacheDelete;
  25. ListCache.prototype.get = listCacheGet;
  26. ListCache.prototype.has = listCacheHas;
  27. ListCache.prototype.set = listCacheSet;
  28. module.exports = ListCache;