New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aofl/cache-manager

Package Overview
Dependencies
Maintainers
2
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aofl/cache-manager - npm Package Compare versions

Comparing version 3.12.1 to 4.0.0-alpha.9

2

dist/index.js

@@ -1,2 +0,2 @@

module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(n,s,function(t){return e[t]}.bind(null,s));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s="QfWi")}({"8vQp":function(e,t){e.exports=require("@babel/runtime/helpers/defineProperty")},MmcY:function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},QfWi:function(e,t,r){"use strict";r.r(t),r.d(t,"CacheManager",(function(){return d})),r.d(t,"cacheTypeEnumerate",(function(){return c})),r.d(t,"MemoryStorage",(function(){return h}));var n,s=r("MmcY"),i=r.n(s),o=r("iTvO"),a=r.n(o),u=r("8vQp"),l=r.n(u),c={MEMORY:0,LOCAL:1,SESSION:2},h=function(){function e(){i()(this,e)}return a()(e,null,[{key:"clear",value:function(){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&e.removeItem(t)}},{key:"getItem",value:function(t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:null}},{key:"setItem",value:function(t,r){e[t]=r}},{key:"removeItem",value:function(t){e[t]=null,delete e[t]}},{key:"size",get:function(){var t=0;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}}]),e}(),y=r("rlan"),p=r.n(y),f=(n={},l()(n,c.LOCAL,localStorage),l()(n,c.SESSION,sessionStorage),l()(n,c.MEMORY,h),n),v=Symbol("expire"),d=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.MEMORY,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:36e5;i()(this,e),this.storage=f[r],this.storageType=r,this.namespace=t,this.storedKeys=this.getStoredKeys(),this.expire=n}return a()(e,[{key:"getStoredKeys",value:function(){var e=[];for(var t in this.storage)Object.hasOwnProperty.call(this.storage,t)&&0===t.indexOf(this.namespace+"_")&&e.push(t);return e}},{key:"getNamespaceKey",value:function(e){return this.storedKeys.indexOf(e)>-1?e:this.namespace+"_"+p()(e)}},{key:"setItem",value:function(e,t){var r={t:Date.now(),v:t};this.storageType!==c.LOCAL&&this.storageType!==c.SESSION||(r=JSON.stringify(r));var n=this.getNamespaceKey(e);this.storage.setItem(n,r),this.storedKeys.push(n)}},{key:"getItem",value:function(e){var t=this.storage.getItem(this.getNamespaceKey(e));return this.storageType!==c.LOCAL&&this.storageType!==c.SESSION||(t=JSON.parse(t)),null!==t&&Object.hasOwnProperty.call(t,"t")?this.isExpired(e)?(this.removeItem(e),null):t.v:t}},{key:"getCollection",value:function(){var e={};this.storedKeys=this.getStoredKeys();for(var t=0;t<this.storedKeys.length;t++)this.isExpired(this.storedKeys[t])||(e[this.storedKeys[t]]=this.getItem(this.storedKeys[t]));return e}},{key:"removeItem",value:function(e){var t=this.getNamespaceKey(e),r=this.storedKeys.indexOf(t);r>-1&&(this.storage.removeItem(t),this.storedKeys.splice(r,1))}},{key:"clear",value:function(){for(var e=0;e<this.storedKeys.length;e++)this.storage.removeItem(this.storedKeys[e]);this.storedKeys=[]}},{key:"isExpired",value:function(e){if("number"!=typeof this.expire||this.expire<=0)return!1;var t=this.getNamespaceKey(e),r=this.storage.getItem(t);if(this.storageType===c.LOCAL||this.storageType===c.SESSION)try{r=JSON.parse(r)}catch(e){}return null===r||r.t<Date.now()-this.expire}},{key:"removeExpired",value:function(){for(var e=0;e<this.storedKeys.length;e++)this.isExpired(this.storedKeys[e])&&this.removeItem(this.storedKeys[e])}},{key:"destruct",value:function(){clearInterval(this.interval),this.namespace=null,this.storage=null,this.storageType=null,this.expire=null,this.storedKeys=null,this.interval=null}},{key:"expire",get:function(){return this[v]},set:function(e){var t=this;this[v]=e,null!==this.interval&&clearInterval(this.interval),e>0&&e<2147483647&&(this.interval=setInterval((function(){return t.removeExpired()}),e))}},{key:"size",get:function(){var e=this.getCollection();return Object.keys(e).length}}]),e}()},iTvO:function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},rlan:function(e,t){e.exports=require("tiny-js-md5")}});
module.exports=function(){"use strict";var e={250:function(e,t,r){r.r(t),r.d(t,{CacheManager:function(){return g},MemoryStorage:function(){return c},cacheTypeEnumerate:function(){return h}});var s,n=require("@babel/runtime/helpers/classCallCheck"),i=r.n(n),o=require("@babel/runtime/helpers/createClass"),a=r.n(o),u=require("@babel/runtime/helpers/defineProperty"),l=r.n(u),h={MEMORY:0,LOCAL:1,SESSION:2},c=function(){function e(){i()(this,e)}return a()(e,null,[{key:"clear",value:function(){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&e.removeItem(t)}},{key:"getItem",value:function(t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:null}},{key:"setItem",value:function(t,r){e[t]=r}},{key:"removeItem",value:function(t){e[t]=null,delete e[t]}},{key:"size",get:function(){var t=0;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}}]),e}(),y=require("tiny-js-md5"),p=r.n(y),v=(s={},l()(s,h.LOCAL,localStorage),l()(s,h.SESSION,sessionStorage),l()(s,h.MEMORY,c),s),f=Symbol("expire"),g=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.MEMORY,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:36e5;i()(this,e),this.storage=v[r],this.storageType=r,this.namespace=t,this.storedKeys=this.getStoredKeys(),this.expire=s}return a()(e,[{key:"getStoredKeys",value:function(){var e=[];for(var t in this.storage)Object.hasOwnProperty.call(this.storage,t)&&0===t.indexOf(this.namespace+"_")&&e.push(t);return e}},{key:"getNamespaceKey",value:function(e){return this.storedKeys.indexOf(e)>-1?e:this.namespace+"_"+p()(e)}},{key:"setItem",value:function(e,t){var r={t:Date.now(),v:t};this.storageType!==h.LOCAL&&this.storageType!==h.SESSION||(r=JSON.stringify(r));var s=this.getNamespaceKey(e);this.storage.setItem(s,r),this.storedKeys.push(s)}},{key:"getItem",value:function(e){var t=this.storage.getItem(this.getNamespaceKey(e));return this.storageType!==h.LOCAL&&this.storageType!==h.SESSION||(t=JSON.parse(t)),null!==t&&Object.hasOwnProperty.call(t,"t")?this.isExpired(e)?(this.removeItem(e),null):t.v:t}},{key:"getCollection",value:function(){var e={};this.storedKeys=this.getStoredKeys();for(var t=0;t<this.storedKeys.length;t++)this.isExpired(this.storedKeys[t])||(e[this.storedKeys[t]]=this.getItem(this.storedKeys[t]));return e}},{key:"removeItem",value:function(e){var t=this.getNamespaceKey(e),r=this.storedKeys.indexOf(t);r>-1&&(this.storage.removeItem(t),this.storedKeys.splice(r,1))}},{key:"clear",value:function(){for(var e=0;e<this.storedKeys.length;e++)this.storage.removeItem(this.storedKeys[e]);this.storedKeys=[]}},{key:"isExpired",value:function(e){if("number"!=typeof this.expire||this.expire<=0)return!1;var t=this.getNamespaceKey(e),r=this.storage.getItem(t);if(this.storageType===h.LOCAL||this.storageType===h.SESSION)try{r=JSON.parse(r)}catch(e){}return null===r||r.t<Date.now()-this.expire}},{key:"removeExpired",value:function(){for(var e=0;e<this.storedKeys.length;e++)this.isExpired(this.storedKeys[e])&&this.removeItem(this.storedKeys[e])}},{key:"destruct",value:function(){clearInterval(this.interval),this.namespace=null,this.storage=null,this.storageType=null,this.expire=null,this.storedKeys=null,this.interval=null}},{key:"expire",get:function(){return this[f]},set:function(e){var t=this;this[f]=e,null!==this.interval&&clearInterval(this.interval),e>0&&e<2147483647&&(this.interval=setInterval((function(){return t.removeExpired()}),e))}},{key:"size",get:function(){var e=this.getCollection();return Object.keys(e).length}}]),e}()}},t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={exports:{}};return e[s](n,n.exports,r),n.exports}return r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(250)}();
//# sourceMappingURL=index.js.map
{
"name": "@aofl/cache-manager",
"version": "3.12.1",
"version": "4.0.0-alpha.9",
"description": "Provides a unified class for storing objects in Storage-like Objects",

@@ -19,4 +19,4 @@ "main": "index.js",

"build-ci": "cross-env NODE_ENV=production aofl build --debug",
"build": "cross-env NODE_ENV=production npx aofl build",
"build:dev": "cross-env NODE_ENV=development npx aofl build",
"build": "cross-env NODE_ENV=production npx @aofl/cli build",
"build:dev": "cross-env NODE_ENV=development npx @aofl/cli build",
"prepublishOnly": "npm run build-ci && npm run docs",

@@ -36,11 +36,11 @@ "docs": "npx jsdoc -c .jsdocrc.json ."

"devDependencies": {
"@aofl/cli": "^3.12.1",
"cross-env": "^6.0.3",
"jsdoc": "^3.6.3",
"tiny-js-md5": "^1.1.2",
"tsd-jsdoc": "^2.4.0"
"@aofl/cli": "^4.0.0-alpha.9",
"cross-env": "^7.0.3",
"jsdoc": "^3.6.6",
"tiny-js-md5": "1.1.2",
"tsd-jsdoc": "^2.5.0"
},
"peerDependencies": {
"tiny-js-md5": ">= 1.1.2 < 2.0.0"
"tiny-js-md5": "^1.1.2"
}
}
/**
* Exports CacheManager, cacheTypeEnumerate, and MemoryStorage
*
* @module @aofl/cache-manager
* @version 3.0.0
* @since 1.0.0
* @author Arian Khosravi <arian.khosravi@aofl.com>
*/

@@ -12,16 +7,10 @@ declare module "@aofl/cache-manager" {

* Creates an instance of CacheManager.
* @param {*} namespace used to group keys controlled by each instance since the starage objects are shared
* @param {*} [storageType=cacheTypeEnumerate.MEMORY] memory, local or session
* @param {number} [expire=3600000] cache expiration in ms
* @param namespace - used to group keys controlled by each instance since the starage objects are shared
* @param [storageType = cacheTypeEnumerate.MEMORY] - memory, local or session
* @param [expire = 3600000] - cache expiration in ms
*/
class CacheManager {
constructor(namespace: any, storageType?: any, expire?: number);
/** @type {cacheTypeEnumerate}
*/
storageType: cacheTypeEnumerate;
/** @type {String}
*/
namespace: string;
/** @type {Number}
*/
expire: number;

@@ -31,5 +20,2 @@ /**

* number of data items stored in the Storage object.
*
* @readonly
* @type {Number}
*/

@@ -39,4 +25,2 @@ readonly size: number;

* Returns keys controlled by the instance of CacheManager
*
* @return {Array}
*/

@@ -46,5 +30,2 @@ getStoredKeys(): any[];

* Returns the serialized key based on namespace
*
* @param {String} key
* @return {String}
*/

@@ -55,5 +36,4 @@ getNamespaceKey(key: string): string;

* that key to the storage, or update that key's value if it already exists
*
* @param {String} key A String containing the name of the key you want to create/update.
* @param {*} value The value you want to give the key you are creating/updating.
* @param key - A String containing the name of the key you want to create/update.
* @param value - The value you want to give the key you are creating/updating.
*/

@@ -64,5 +44,3 @@ setItem(key: string, value: any): void;

* key's value or null if the key does not exist.
*
* @param {String} key The name of the key you want to retrieve the value of
* @return {*}
* @param key - The name of the key you want to retrieve the value of
*/

@@ -73,4 +51,2 @@ getItem(key: string): any;

* pairs that that instance of CacheManager tracks.
*
* @return {Object}
*/

@@ -82,4 +58,3 @@ getCollection(): any;

* method will do nothing.
*
* @param {String} key The name of the key you want to remove
* @param key - The name of the key you want to remove
*/

@@ -94,5 +69,3 @@ removeItem(key: string): void;

* is expired.
*
* @param {String} key The name of the key you want to check if is expired.
* @return {Boolean}
* @param key - The name of the key you want to check if is expired.
*/

@@ -113,18 +86,17 @@ isExpired(key: string): boolean;

* Cache types enumerate
*
* @memberof module:@aofl/cache-manager
* @readonly
* @static
* @enum {Number}
*/
const enum cacheTypeEnumerate {
/**
* memoryStorage
*/
MEMORY = 0,
/**
* localStorage
*/
LOCAL = 1,
/**
* sessionStorage
*/
SESSION = 2
}
/**
*
*
* @memberof module:@aofl/cache-manager
*/
class MemoryStorage {

@@ -138,5 +110,2 @@ /**

* number of data items stored in the Storage object.
*
* @readonly
* @type {Number}
*/

@@ -147,5 +116,3 @@ static readonly size: number;

* value or null if the key does not exist.
*
* @param {String} key The name of the key you want to retrieve the value of.
* @return {*}
* @param key - The name of the key you want to retrieve the value of.
*/

@@ -156,5 +123,4 @@ static getItem(key: string): any;

* that key to the storage, or update that key's value if it already exists.
*
* @param {*} key The name of the key you want to create/update.
* @param {*} value The value you want to give the key you are creating/updating.
* @param key - The name of the key you want to create/update.
* @param value - The value you want to give the key you are creating/updating.
*/

@@ -166,4 +132,3 @@ static setItem(key: any, value: any): void;

* will do nothing.
*
* @param {String} key The name of the key you want to remove.
* @param key - The name of the key you want to remove.
*/

@@ -170,0 +135,0 @@ static removeItem(key: string): void;

Sorry, the diff of this file is not supported yet

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