_SetCache.js 630 B

123456789101112131415161718192021222324252627
  1. import MapCache from './_MapCache.js';
  2. import setCacheAdd from './_setCacheAdd.js';
  3. import setCacheHas from './_setCacheHas.js';
  4. /**
  5. *
  6. * Creates an array cache object to store unique values.
  7. *
  8. * @private
  9. * @constructor
  10. * @param {Array} [values] The values to cache.
  11. */
  12. function SetCache(values) {
  13. var index = -1,
  14. length = values == null ? 0 : values.length;
  15. this.__data__ = new MapCache;
  16. while (++index < length) {
  17. this.add(values[index]);
  18. }
  19. }
  20. // Add methods to `SetCache`.
  21. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  22. SetCache.prototype.has = setCacheHas;
  23. export default SetCache;