mirror of https://github.com/lukechilds/node.git
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.
31 lines
776 B
31 lines
776 B
var stackClear = require('./_stackClear'),
|
|
stackDelete = require('./_stackDelete'),
|
|
stackGet = require('./_stackGet'),
|
|
stackHas = require('./_stackHas'),
|
|
stackSet = require('./_stackSet');
|
|
|
|
/**
|
|
* Creates a stack cache object to store key-value pairs.
|
|
*
|
|
* @private
|
|
* @param {Array} [values] The values to cache.
|
|
*/
|
|
function Stack(values) {
|
|
var index = -1,
|
|
length = values ? values.length : 0;
|
|
|
|
this.clear();
|
|
while (++index < length) {
|
|
var entry = values[index];
|
|
this.set(entry[0], entry[1]);
|
|
}
|
|
}
|
|
|
|
// Add functions to the `Stack` cache.
|
|
Stack.prototype.clear = stackClear;
|
|
Stack.prototype['delete'] = stackDelete;
|
|
Stack.prototype.get = stackGet;
|
|
Stack.prototype.has = stackHas;
|
|
Stack.prototype.set = stackSet;
|
|
|
|
module.exports = Stack;
|
|
|