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.

_listCacheDelete.js 775B

1234567891011121314151617181920212223242526272829303132333435
  1. var assocIndexOf = require('./_assocIndexOf');
  2. /** Used for built-in method references. */
  3. var arrayProto = Array.prototype;
  4. /** Built-in value references. */
  5. var splice = arrayProto.splice;
  6. /**
  7. * Removes `key` and its value from the list cache.
  8. *
  9. * @private
  10. * @name delete
  11. * @memberOf ListCache
  12. * @param {string} key The key of the value to remove.
  13. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  14. */
  15. function listCacheDelete(key) {
  16. var data = this.__data__,
  17. index = assocIndexOf(data, key);
  18. if (index < 0) {
  19. return false;
  20. }
  21. var lastIndex = data.length - 1;
  22. if (index == lastIndex) {
  23. data.pop();
  24. } else {
  25. splice.call(data, index, 1);
  26. }
  27. --this.size;
  28. return true;
  29. }
  30. module.exports = listCacheDelete;