lru-cache.js
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,1 +0,1 @@ | ||
var LRUCache,bind=function(t,i){return function(){return t.apply(i,arguments)}},indexOf=[].indexOf||function(t){for(var i=0,s=this.length;s>i;i++)if(i in this&&this[i]===t)return i;return-1};LRUCache=function(){function t(t){this.size=null!=t?t:10,this.rawDict=bind(this.rawDict,this),this.dict=bind(this.dict,this),this.setSize=bind(this.setSize,this),this.clear=bind(this.clear,this),this.forEach=bind(this.forEach,this),this.get=bind(this.get,this),this.put=bind(this.put,this),this._keys=[],this._data={}}return t.prototype.put=function(t,i){var s;return s=this._keys.indexOf(t),s>=0&&this._keys.splice(s,1),this._data[t]=i,this._keys.push(t),this._keys.length>this.size&&delete this._data[this._keys.shift()],!0},t.prototype.get=function(t){var i;if(!(indexOf.call(this._keys,t)<0))return i=this._keys.indexOf(t),i>=0?i!==this._keys.length-1&&(this._keys.splice(i,1),this._keys.push(t)):this._keys.push(t),this._data[t]||null},t.prototype.forEach=function(t){var i,s,e,h;s=this._data,e=[];for(i in s)h=s[i],e.push(t(h,i));return e},t.prototype.map=function(t){var i,s,e,h;e={},s=this._data;for(i in s)h=s[i],Object.assign(e,t(h,i));return e},t.prototype.clear=function(){return this._keys=[],this._data={}},t.prototype.setSize=function(t){var i;if(this.size!==t){for(this.size=t,i=[];this._keys.length>t;)i.push(delete this._data[this._keys.shift()]);return i}},t.prototype.dict=function(){return Object.assign({},this._data)},t.prototype.rawDict=function(){return this._data},t}(),module.exports=LRUCache; | ||
var LRUCache,bind=function(t,i){return function(){return t.apply(i,arguments)}},indexOf=[].indexOf||function(t){for(var i=0,s=this.length;s>i;i++)if(i in this&&this[i]===t)return i;return-1};LRUCache=function(){function t(t){this.size=null!=t?t:10,this.contains=bind(this.contains,this),this["delete"]=bind(this["delete"],this),this.rawDict=bind(this.rawDict,this),this.dict=bind(this.dict,this),this.setSize=bind(this.setSize,this),this.clear=bind(this.clear,this),this.forEach=bind(this.forEach,this),this.get=bind(this.get,this),this.put=bind(this.put,this),this._keys=[],this._data={}}return t.prototype.put=function(t,i){var s;return s=this._keys.indexOf(t),s>=0&&this._keys.splice(s,1),this._data[t]=i,this._keys.push(t),this._keys.length>this.size&&delete this._data[this._keys.shift()],!0},t.prototype.get=function(t){var i;if(!(indexOf.call(this._keys,t)<0))return i=this._keys.indexOf(t),i>=0?i!==this._keys.length-1&&(this._keys.splice(i,1),this._keys.push(t)):this._keys.push(t),this._data[t]||null},t.prototype.forEach=function(t){var i,s,e,h;s=this._data,e=[];for(i in s)h=s[i],e.push(t(h,i));return e},t.prototype.map=function(t){var i,s,e,h;e={},s=this._data;for(i in s)h=s[i],Object.assign(e,t(h,i));return e},t.prototype.clear=function(){return this._keys=[],this._data={}},t.prototype.setSize=function(t){var i;if(this.size!==t){for(this.size=t,i=[];this._keys.length>t;)i.push(delete this._data[this._keys.shift()]);return i}},t.prototype.dict=function(){return Object.assign({},this._data)},t.prototype.rawDict=function(){return this._data},t.prototype["delete"]=function(t){var i;return i=this._keys.indexOf(t),0>i?!1:(this._keys.splice(i,1),delete this._data[t],!0)},t.prototype.contains=function(t){return t in this._data},t}(),module.exports=LRUCache; |
{ | ||
"name": "lru-cache.js", | ||
"version": "1.0.0", | ||
"description": "A simple in-memory LRU cache", | ||
"version": "1.0.1", | ||
"description": "A simple in-memory LRU cache with no dependencies", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Alex Lau" |
# lru-cache.js | ||
A simple in-memory LRU cache | ||
A simple in-memory LRU cache with no dependencies |
2386
4