mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
32
.internal/listCacheDelete.js
Normal file
32
.internal/listCacheDelete.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import assocIndexOf from './.internal/assocIndexOf.js';
|
||||
|
||||
/** Built-in value references. */
|
||||
const splice = Array.prototype.splice;
|
||||
|
||||
/**
|
||||
* Removes `key` and its value from the list cache.
|
||||
*
|
||||
* @private
|
||||
* @name delete
|
||||
* @memberOf ListCache
|
||||
* @param {string} key The key of the value to remove.
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function listCacheDelete(key) {
|
||||
const data = this.__data__;
|
||||
const index = assocIndexOf(data, key);
|
||||
|
||||
if (index < 0) {
|
||||
return false;
|
||||
}
|
||||
const lastIndex = data.length - 1;
|
||||
if (index == lastIndex) {
|
||||
data.pop();
|
||||
} else {
|
||||
splice.call(data, index, 1);
|
||||
}
|
||||
--this.size;
|
||||
return true;
|
||||
}
|
||||
|
||||
export default listCacheDelete;
|
||||
Reference in New Issue
Block a user