_ListCache.js 867 B

1234567891011121314151617181920212223242526272829303132
  1. import listCacheClear from './_listCacheClear.js';
  2. import listCacheDelete from './_listCacheDelete.js';
  3. import listCacheGet from './_listCacheGet.js';
  4. import listCacheHas from './_listCacheHas.js';
  5. import listCacheSet from './_listCacheSet.js';
  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. export default ListCache;