Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cache-lru

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-lru - npm Package Compare versions

Comparing version 1.0.19 to 1.1.0

eslint.yaml

34

Gruntfile.js

@@ -27,11 +27,11 @@ /*

module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-contrib-clean")
grunt.loadNpmTasks("grunt-browserify")
grunt.loadNpmTasks("grunt-mocha-test")
grunt.loadNpmTasks("grunt-eslint")
grunt.initConfig({
jshint: {
eslint: {
options: {
jshintrc: "jshint.json"
configFile: "eslint.yaml"
},

@@ -47,5 +47,15 @@ "gruntfile": [ "Gruntfile.js" ],

options: {
transform: [ [ "babelify", { presets: [ "es2015" ] } ] ],
transform: [
[ "babelify", {
presets: [
[ "env", {
"targets": {
"browser": [ "last 2 versions" ]
}
} ]
]
} ],
[ "uglifyify", { sourceMap: false, global: true } ]
],
plugin: [
[ "minifyify" ],
[ "browserify-derequire" ],

@@ -56,3 +66,3 @@ [ "browserify-header" ]

standalone: "CacheLRU",
debug: true
debug: false
}

@@ -75,6 +85,6 @@ }

}
});
})
grunt.registerTask("default", [ "jshint", "browserify", "mochaTest" ]);
};
grunt.registerTask("default", [ "eslint", "browserify", "mochaTest" ])
}

@@ -26,7 +26,4 @@ /*

(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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({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")}var _createClass=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),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){return void 0!==this._index[e]}},{key:"peek",value:function(e){var t=this._index[e];if(void 0!==t)return t.expires<Date.now()?void this.del(t.key):t.val}},{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)return t.expires<Date.now()?void this.del(t.key):(this._promote(t),t.val)}},{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";var _createClass=function(){function e(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)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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){return void 0!==this._index[e]}},{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;
},{}]},{},[1])(1)
});
//# sourceMappingURL=bundle.map
});
{
"name": "cache-lru",
"version": "1.0.19",
"version": "1.1.0",
"description": "In-Memory Cache with O(1) Operations and LRU Purging Strategy",

@@ -23,17 +23,28 @@ "keywords": [ "cache", "lru" ],

"devDependencies": {
"grunt": "~1.0.2",
"grunt-cli": "~1.2.0",
"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-clean": "~1.1.0",
"grunt-browserify": "~5.2.0",
"grunt-mocha-test": "~0.13.3",
"mocha": "~5.0.4",
"chai": "~4.1.2",
"babelify": "~8.0.0",
"babel-core": "~6.26.0",
"babel-preset-es2015": "~6.24.1",
"minifyify": "~7.3.5",
"browserify-header": "~0.9.2",
"browserify-derequire": "~0.9.4"
"grunt": "1.0.2",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "1.1.0",
"grunt-browserify": "5.2.0",
"grunt-mocha-test": "0.13.3",
"grunt-eslint": "20.1.0",
"babel-eslint": "8.2.2",
"eslint": "4.19.1",
"eslint-config-standard": "11.0.0",
"eslint-plugin-standard": "3.0.1",
"eslint-plugin-promise": "3.7.0",
"eslint-plugin-import": "2.9.0",
"eslint-plugin-node": "6.0.1",
"mocha": "5.0.4",
"chai": "4.1.2",
"babelify": "8.0.0",
"babel-core": "6.26.0",
"babel-preset-env": "1.6.1",
"uglifyify": "4.0.5",
"browserify-header": "0.9.2",
"browserify-derequire": "0.9.4"
},
"scripts": {
"prepublishOnly": "grunt default",
"build": "grunt default"
}
}

@@ -25,4 +25,2 @@

#### Node environments (with NPM package manager):
```shell

@@ -32,8 +30,2 @@ $ npm install cache-lru

#### Browser environments (with Bower package manager):
```shell
$ bower install cache-lru
```
Usage

@@ -40,0 +32,0 @@ -----

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc