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.3 to 1.0.4

2

bower.json
{
"name": "cache-lru",
"version": "1.0.3",
"version": "1.0.4",
"description": "In-Memory Cache with O(1) Operations and LRU Purging Strategy",

@@ -5,0 +5,0 @@ "main": "lib/cache-lru.js",

@@ -46,3 +46,3 @@ /*

options: {
transform: [ "6to5ify" ],
transform: [ "babelify" ],
plugin: [

@@ -49,0 +49,0 @@ [ "minifyify" ],

@@ -25,4 +25,4 @@ /*

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.CacheLRU=e()}}(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";var _prototypeProperties=function(e,t,i){t&&Object.defineProperties(e,t),i&&Object.defineProperties(e.prototype,i)},_classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},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 _prototypeProperties(e,null,{limit:{value:function(e){var t=this._max;return arguments.length>0&&(this._max=e,this._purge()),t},writable:!0,configurable:!0},dispose:{value:function(e){return this._dispose=e,this},writable:!0,configurable:!0},length:{value:function(){return this._cur},writable:!0,configurable:!0},keys:{value:function(){return this.each(function(e,t){this.push(t)},[])},writable:!0,configurable:!0},values:{value:function(){return this.each(function(e){this.push(e)},[])},writable:!0,configurable:!0},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},writable:!0,configurable:!0},has:{value:function(e){var t=this._index[e];return void 0!==t},writable:!0,configurable:!0},peek:{value:function(e){var t=this._index[e];return void 0===t?void 0:t.expires<Date.now()?void this.del(t.key):t.val},writable:!0,configurable:!0},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},writable:!0,configurable:!0},get:{value:function(e){var t=this._index[e];return void 0===t?void 0:t.expires<Date.now()?void this.del(t.key):(this._promote(t),t.val)},writable:!0,configurable:!0},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},writable:!0,configurable:!0},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},writable:!0,configurable:!0},clear:{value:function(){for(;this._cur>0;)this.del(this._LRU.newer.key);return this},writable:!0,configurable:!0},_purge:{value:function(){for(;this._cur>this._max;)this.del(this._LRU.newer.key)},writable:!0,configurable:!0},_promote:{value:function(e){this._detach(e),this._attach(e)},writable:!0,configurable:!0},_detach:{value:function(e){e.older.newer=e.newer,e.newer.older=e.older,e.older=null,e.newer=null},writable:!0,configurable:!0},_attach:{value:function(e){e.older=this._MRU.older,e.newer=this._MRU,e.newer.older=e,e.older.newer=e},writable:!0,configurable:!0}}),e}();module.exports=CacheLRU;
(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";var _classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},_createClass=function(){function e(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,r.key,r)}}return function(t,i,r){return i&&e(t.prototype,i),r&&e(t,r),t}}();Object.defineProperty(exports,"__esModule",{value:!0});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}},{key:"peek",value:function(e){var t=this._index[e];return void 0===t?void 0: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];return void 0===t?void 0: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 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}();exports["default"]=CacheLRU,module.exports=exports["default"];
},{}]},{},[1])(1)

@@ -29,0 +29,0 @@ });

{
"name": "cache-lru",
"version": "1.0.3",
"version": "1.0.4",
"description": "In-Memory Cache with O(1) Operations and LRU Purging Strategy",

@@ -25,12 +25,12 @@ "keywords": [ "cache", "lru" ],

"grunt-cli": "~0.1.13",
"grunt-contrib-jshint": "~0.11.0",
"grunt-contrib-jshint": "~0.11.1",
"grunt-contrib-clean": "~0.6.0",
"grunt-browserify": "~3.3.0",
"grunt-browserify": "~3.6.0",
"grunt-mocha-test": "~0.12.7",
"chai": "~2.0.0",
"6to5ify": "~4.1.1",
"minifyify": "~6.2.2",
"browserify-header": "~0.9.1",
"browserify-derequire": "~0.9.2"
"chai": "~2.2.0",
"babelify": "~6.0.1",
"minifyify": "~6.4.0",
"browserify-header": "~0.9.2",
"browserify-derequire": "~0.9.4"
}
}
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