_Hash.js 747 B

123456789101112131415161718192021222324252627282930313233
  1. var hashClear = require('./_hashClear'),
  2. hashDelete = require('./_hashDelete'),
  3. hashGet = require('./_hashGet'),
  4. hashHas = require('./_hashHas'),
  5. hashSet = require('./_hashSet');
  6. /**
  7. * Creates a hash object.
  8. *
  9. * @private
  10. * @constructor
  11. * @param {Array} [entries] The key-value pairs to cache.
  12. */
  13. function Hash(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 `Hash`.
  23. Hash.prototype.clear = hashClear;
  24. Hash.prototype['delete'] = hashDelete;
  25. Hash.prototype.get = hashGet;
  26. Hash.prototype.has = hashHas;
  27. Hash.prototype.set = hashSet;
  28. module.exports = Hash;