mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Make MapCache, SetCache, and Stack add values left to right.
This commit is contained in:
32
lodash.js
32
lodash.js
@@ -1773,14 +1773,12 @@
|
|||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function MapCache(values) {
|
function MapCache(values) {
|
||||||
this.__data__ = {
|
var index = -1,
|
||||||
'hash': new Hash,
|
length = values ? values.length : 0;
|
||||||
'map': Map ? new Map : [],
|
|
||||||
'string': new Hash
|
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
|
||||||
};
|
while (++index < length) {
|
||||||
var length = values ? values.length : 0;
|
var entry = values[index];
|
||||||
while (length--) {
|
|
||||||
var entry = values[length];
|
|
||||||
this.set(entry[0], entry[1]);
|
this.set(entry[0], entry[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1868,10 +1866,12 @@
|
|||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function SetCache(values) {
|
function SetCache(values) {
|
||||||
|
var index = -1,
|
||||||
|
length = values ? values.length : 0;
|
||||||
|
|
||||||
this.__data__ = new MapCache;
|
this.__data__ = new MapCache;
|
||||||
var length = values ? values.length : 0;
|
while (++index < length) {
|
||||||
while (length--) {
|
this.push(values[index]);
|
||||||
this.push(values[length]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1922,9 +1922,17 @@
|
|||||||
* Creates a stack cache object to store key-value pairs.
|
* Creates a stack cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function Stack() {
|
function Stack(values) {
|
||||||
|
var index = -1,
|
||||||
|
length = values ? values.length : 0;
|
||||||
|
|
||||||
this.__data__ = { 'array': [], 'map': null };
|
this.__data__ = { 'array': [], 'map': null };
|
||||||
|
while (++index < length) {
|
||||||
|
var entry = values[index];
|
||||||
|
this.set(entry[0], entry[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user