Comparing version 1.1.11 to 1.2.0
/* | ||
** Cache-LRU -- In-Memory Cache with O(1) Operations and LRU Purging Strategy | ||
** Copyright (c) 2015-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2015-2024 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -36,3 +36,3 @@ ** Permission is hereby granted, free of charge, to any person obtaining | ||
options: { | ||
configFile: "eslint.yaml" | ||
overrideConfigFile: "eslint.yaml" | ||
}, | ||
@@ -39,0 +39,0 @@ "gruntfile": [ "Gruntfile.js" ], |
/* | ||
** Cache-LRU -- In-Memory Cache with O(1) Operations and LRU Purging Strategy | ||
** Copyright (c) 2015-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2015-2024 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -26,4 +26,4 @@ ** Permission is hereby granted, free of charge, to any person obtaining | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.CacheLRU = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){ | ||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),e}var CacheLRU=function(){function e(){return _classCallCheck(this,e),this._index={},this._LRU={newer:null},this._MRU={older:null},this._LRU.newer=this._MRU,this._MRU.older=this._LRU,this._cur=0,this._max=1/0,this._dispose=function(){},this}return _createClass(e,[{key:"limit",value:function(e){var t=this._max;return arguments.length>0&&(this._max=e,this._purge()),t}},{key:"dispose",value:function(e){return this._dispose=e,this}},{key:"length",value:function(){return this._cur}},{key:"keys",value:function(){return this.each(function(e,t){this.push(t)},[])}},{key:"values",value:function(){return this.each(function(e){this.push(e)},[])}},{key:"each",value:function(e,t){arguments<2&&(t=this);for(var i=0,n=this._MRU.older;n!==this._LRU;)e.call(t,n.val,n.key,i++),n=n.older;return t}},{key:"has",value:function(e){var t=this._index[e];return void 0!==t&&t.expires>=Date.now()}},{key:"peek",value:function(e){var t=this._index[e];if(void 0!==t){if(!(t.expires<Date.now()))return t.val;this.del(t.key)}}},{key:"touch",value:function(e){var t=this._index[e];if(void 0===t)throw new Error("touch: no such item");return this._promote(t),this}},{key:"get",value:function(e){var t=this._index[e];if(void 0!==t){if(!(t.expires<Date.now()))return this._promote(t),t.val;this.del(t.key)}}},{key:"set",value:function(e,t,i){arguments.length<3&&(i=1/0),i+=Date.now();var n=this._index[e];if(void 0===n)n={older:null,newer:null,key:e,val:t,expires:i},this._index[e]=n,this._attach(n),this._cur++,this._purge();else{var r=n.val;n.val=t,this._promote(n),this._dispose.call(void 0,n.key,r,"set")}return this}},{key:"del",value:function(e){var t=this._index[e];if(void 0===t)throw new Error("del: no such item");return delete this._index[e],this._detach(t),this._cur--,this._dispose.call(void 0,e,t.val,"del"),this}},{key:"clear",value:function(){for(;this._cur>0;)this.del(this._LRU.newer.key);return this}},{key:"_purge",value:function(){for(;this._cur>this._max;)this.del(this._LRU.newer.key)}},{key:"_promote",value:function(e){this._detach(e),this._attach(e)}},{key:"_detach",value:function(e){e.older.newer=e.newer,e.newer.older=e.older,e.older=null,e.newer=null}},{key:"_attach",value:function(e){e.older=this._MRU.older,e.newer=this._MRU,e.newer.older=e,e.older.newer=e}}]),e}();module.exports=CacheLRU; | ||
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var CacheLRU=function(){function e(){return _classCallCheck(this,e),this._index={},this._LRU={newer:null},this._MRU={older:null},this._LRU.newer=this._MRU,this._MRU.older=this._LRU,this._cur=0,this._max=1/0,this._dispose=function(){},this}return _createClass(e,[{key:"limit",value:function(e){var t=this._max;return arguments.length>0&&(this._max=e,this._purge()),t}},{key:"dispose",value:function(e){return this._dispose=e,this}},{key:"length",value:function(){return this._cur}},{key:"keys",value:function(){return this.each(function(e,t){this.push(t)},[])}},{key:"values",value:function(){return this.each(function(e){this.push(e)},[])}},{key:"each",value:function(e,t){arguments<2&&(t=this);for(var i=0,r=this._MRU.older;r!==this._LRU;)e.call(t,r.val,r.key,i++),r=r.older;return t}},{key:"has",value:function(e){var t=this._index[e];return void 0!==t&&t.expires>=Date.now()}},{key:"peek",value:function(e){var t=this._index[e];if(void 0!==t){if(!(t.expires<Date.now()))return t.val;this.del(t.key)}}},{key:"touch",value:function(e){var t=this._index[e];if(void 0===t)throw new Error("touch: no such item");return this._promote(t),this}},{key:"get",value:function(e){var t=this._index[e];if(void 0!==t){if(!(t.expires<Date.now()))return this._promote(t),t.val;this.del(t.key)}}},{key:"set",value:function(e,t,i){arguments.length<3&&(i=1/0),i+=Date.now();var r=this._index[e];if(void 0===r)r={older:null,newer:null,key:e,val:t,expires:i},this._index[e]=r,this._attach(r),this._cur++,this._purge();else{var n=r.val;r.val=t,this._promote(r),this._dispose.call(void 0,r.key,n,"set")}return this}},{key:"del",value:function(e){var t=this._index[e];if(void 0===t)throw new Error("del: no such item");return delete this._index[e],this._detach(t),this._cur--,this._dispose.call(void 0,e,t.val,"del"),this}},{key:"clear",value:function(){for(;this._cur>0;)this.del(this._LRU.newer.key);return this}},{key:"_purge",value:function(){for(;this._cur>this._max;)this.del(this._LRU.newer.key)}},{key:"_promote",value:function(e){this._detach(e),this._attach(e)}},{key:"_detach",value:function(e){e.older.newer=e.newer,e.newer.older=e.older,e.older=null,e.newer=null}},{key:"_attach",value:function(e){e.older=this._MRU.older,e.newer=this._MRU,e.newer.older=e,e.older.newer=e}}]),e}();module.exports=CacheLRU; | ||
},{}]},{},[1])(1) | ||
}); |
{ | ||
"name": "cache-lru", | ||
"version": "1.1.11", | ||
"version": "1.2.0", | ||
"description": "In-Memory Cache with O(1) Operations and LRU Purging Strategy", | ||
@@ -9,3 +9,3 @@ "keywords": [ "cache", "lru" ], | ||
"type": "git", | ||
"url": "https://github.com/rse/cache-lru.git" | ||
"url": "git+https://github.com/rse/cache-lru.git" | ||
}, | ||
@@ -21,22 +21,21 @@ "author": { | ||
"devDependencies": { | ||
"grunt": "1.3.0", | ||
"grunt-cli": "1.3.2", | ||
"grunt-contrib-clean": "2.0.0", | ||
"grunt-browserify": "5.3.0", | ||
"grunt": "1.6.1", | ||
"grunt-cli": "1.4.3", | ||
"grunt-contrib-clean": "2.0.1", | ||
"grunt-browserify": "6.0.0", | ||
"grunt-mocha-test": "0.13.3", | ||
"grunt-eslint": "23.0.0", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "7.16.0", | ||
"eslint-config-standard": "16.0.2", | ||
"eslint-plugin-promise": "4.2.1", | ||
"eslint-plugin-import": "2.22.1", | ||
"grunt-eslint": "24.3.0", | ||
"eslint": "8.57.0", | ||
"eslint-config-standard": "17.1.0", | ||
"eslint-plugin-promise": "6.1.1", | ||
"eslint-plugin-import": "2.29.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"mocha": "8.2.1", | ||
"chai": "4.2.0", | ||
"mocha": "10.3.0", | ||
"chai": "4.4.1", | ||
"babelify": "10.0.0", | ||
"@babel/core": "7.12.10", | ||
"@babel/preset-env": "7.12.11", | ||
"@babel/core": "7.24.0", | ||
"@babel/preset-env": "7.24.0", | ||
"uglifyify": "5.0.2", | ||
"browserify-header": "1.0.1", | ||
"browserify-derequire": "1.0.1" | ||
"browserify-header": "1.1.0", | ||
"browserify-derequire": "1.1.1" | ||
}, | ||
@@ -43,0 +42,0 @@ "scripts": { |
@@ -119,3 +119,3 @@ | ||
Copyright (c) 2015-2019 Dr. Ralf S. Engelschall (http://engelschall.com/) | ||
Copyright (c) 2015-2024 Dr. Ralf S. Engelschall (http://engelschall.com/) | ||
@@ -122,0 +122,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
/* | ||
** Cache-LRU -- In-Memory Cache with O(1) Operations and LRU Purging Strategy | ||
** Copyright (c) 2015-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2015-2024 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -134,5 +134,5 @@ ** Permission is hereby granted, free of charge, to any person obtaining | ||
newer: null, | ||
key: key, | ||
val: val, | ||
expires: expires | ||
key, | ||
val, | ||
expires | ||
} | ||
@@ -139,0 +139,0 @@ this._index[key] = bucket |
/* | ||
** Cache-LRU -- In-Memory Cache with O(1) Operations and LRU Purging Strategy | ||
** Copyright (c) 2015-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2015-2024 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -5,0 +5,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
/* | ||
** Cache-LRU -- In-Memory Cache with O(1) Operations and LRU Purging Strategy | ||
** Copyright (c) 2015-2019 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** Copyright (c) 2015-2024 Dr. Ralf S. Engelschall <rse@engelschall.com> | ||
** | ||
@@ -5,0 +5,0 @@ ** Permission is hereby granted, free of charge, to any person obtaining |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30608
19
410