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.

27 line
632 B

4 年之前
  1. var MapCache = require('./_MapCache'),
  2. setCacheAdd = require('./_setCacheAdd'),
  3. setCacheHas = require('./_setCacheHas');
  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. module.exports = SetCache;