Socket
Socket
Sign inDemoInstall

@jaysalvat/super-storage

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

2

build/super-storage.esm.js

@@ -6,3 +6,3 @@

* https://github.com/jaysalvat/super-store
* @version 1.1.0 built 2021-02-17 15:07:10
* @version 1.1.2 built 2021-02-17 15:29:02
* @license ISC

@@ -9,0 +9,0 @@ * @author Jay Salvat http://jaysalvat.com

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

/*! super-storage v1.1.0 */
/*! super-storage v1.1.2 */
var e={storagePrefix:"",sessionCookieName:"__superStorageSession",sessionNative:!1,sessionPrefix:"session",cookiePrefix:"",cookieOptions:{domain:null,path:null,maxAge:null,expires:null,secure:null}};class s{constructor(s={}){this.settings=Object.assign({},e,s)}setItem(e,s,t={}){t=this.mergeOptions(t),document.cookie=this.key(e)+"="+JSON.stringify(s)+";"+this.buildOptionString(t)}getItem(e,s=null){const t=document.cookie.match("(^|;)\\s*"+this.key(e)+"\\s*=\\s*([^;]+)"),i=t?t.pop():s;try{return JSON.parse(i)}catch(e){return i}}removeItem(e,s={}){s=this.mergeOptions(s),document.cookie=this.key(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT;"+this.buildOptionString({domain:s.domain,path:s.path})}mergeOptions(s){return Object.assign({},e.cookieOptions,s)}buildOptionString(e){let s="";if(e.expires){const t=new Date;t.setTime(t.getTime()+1e3*e.expires),s+="expires="+t.toUTCString()+";"}return e.maxAge&&(s+="max-age="+e.maxAge+";"),e.path&&(s+="path="+e.path+";"),e.domain&&(s+="domain="+e.domain+";"),e.secure&&(s+="secure;"),s}key(e){const s=[];return this.settings.cookiePrefix&&s.push(this.settings.cookiePrefix),s.push(e),s.join(".")}}class t{constructor(s,t={}){this.storage=s,this.settings=Object.assign({},e,t)}getItem(e,s=null){const t=this.storage.getItem(this.key(e));if(!t)return s;try{return JSON.parse(t)}catch(e){return t}}setItem(e,s){return"object"==typeof s&&(s=JSON.stringify(s)),this.storage.setItem(this.key(e),s)}removeItem(e){return this.storage.removeItem(this.key(e))}clear(e=null){if(e){Object.keys(this.storage).forEach((s=>{0===s.indexOf(this.key(e))&&this.storage.removeItem(s)}))}else this.storage.clear()}key(e){const s=[];return this.settings.storagePrefix&&s.push(this.settings.storagePrefix),s.push(e),s.join(".")}}class i extends t{constructor(e={}){super(window.localStorage,e)}}class o extends t{constructor(t={}){(t=Object.assign({},e,t,{cookiePrefix:null})).sessionNative?super(window.sessionStorage,t):super(window.localStorage,t),this.settings.sessionNative||(this.superCookie=new s(this.settings),this.checkSession()||this.killSession())}getItem(e,s=null){return super.getItem(this.sessionKey(e),s)}setItem(e,s){return super.setItem(this.sessionKey(e),s)}removeItem(e){return super.removeItem(this.sessionKey(e))}clear(){return super.clear(this.sessionKey(""))}sessionKey(e){const s=[e];return this.settings.sessionNative?e:(this.settings.sessionPrefix&&s.unshift(this.settings.sessionPrefix),s.join("."))}checkSession(){return!!this.superCookie.getItem(this.settings.sessionCookieName)}killSession(){this.superCookie.setItem(this.settings.sessionCookieName,"YES",{domain:window.location.hostname,path:"/",maxAge:null,expires:null,secure:!1}),this.clear()}}export{s as SuperCookie,i as SuperLocalStorage,o as SuperSessionStorage};

@@ -6,3 +6,3 @@

* https://github.com/jaysalvat/super-store
* @version 1.1.0 built 2021-02-17 15:07:10
* @version 1.1.2 built 2021-02-17 15:29:02
* @license ISC

@@ -9,0 +9,0 @@ * @author Jay Salvat http://jaysalvat.com

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

/*! super-storage v1.1.0 */
/*! super-storage v1.1.2 */
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).superStorage={})}(this,(function(e){"use strict";var s={storagePrefix:"",sessionCookieName:"__superStorageSession",sessionNative:!1,sessionPrefix:"session",cookiePrefix:"",cookieOptions:{domain:null,path:null,maxAge:null,expires:null,secure:null}};class t{constructor(e={}){this.settings=Object.assign({},s,e)}setItem(e,s,t={}){t=this.mergeOptions(t),document.cookie=this.key(e)+"="+JSON.stringify(s)+";"+this.buildOptionString(t)}getItem(e,s=null){const t=document.cookie.match("(^|;)\\s*"+this.key(e)+"\\s*=\\s*([^;]+)"),i=t?t.pop():s;try{return JSON.parse(i)}catch(e){return i}}removeItem(e,s={}){s=this.mergeOptions(s),document.cookie=this.key(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT;"+this.buildOptionString({domain:s.domain,path:s.path})}mergeOptions(e){return Object.assign({},s.cookieOptions,e)}buildOptionString(e){let s="";if(e.expires){const t=new Date;t.setTime(t.getTime()+1e3*e.expires),s+="expires="+t.toUTCString()+";"}return e.maxAge&&(s+="max-age="+e.maxAge+";"),e.path&&(s+="path="+e.path+";"),e.domain&&(s+="domain="+e.domain+";"),e.secure&&(s+="secure;"),s}key(e){const s=[];return this.settings.cookiePrefix&&s.push(this.settings.cookiePrefix),s.push(e),s.join(".")}}class i{constructor(e,t={}){this.storage=e,this.settings=Object.assign({},s,t)}getItem(e,s=null){const t=this.storage.getItem(this.key(e));if(!t)return s;try{return JSON.parse(t)}catch(e){return t}}setItem(e,s){return"object"==typeof s&&(s=JSON.stringify(s)),this.storage.setItem(this.key(e),s)}removeItem(e){return this.storage.removeItem(this.key(e))}clear(e=null){if(e){Object.keys(this.storage).forEach((s=>{0===s.indexOf(this.key(e))&&this.storage.removeItem(s)}))}else this.storage.clear()}key(e){const s=[];return this.settings.storagePrefix&&s.push(this.settings.storagePrefix),s.push(e),s.join(".")}}e.SuperCookie=t,e.SuperLocalStorage=class extends i{constructor(e={}){super(window.localStorage,e)}},e.SuperSessionStorage=class extends i{constructor(e={}){(e=Object.assign({},s,e,{cookiePrefix:null})).sessionNative?super(window.sessionStorage,e):super(window.localStorage,e),this.settings.sessionNative||(this.superCookie=new t(this.settings),this.checkSession()||this.killSession())}getItem(e,s=null){return super.getItem(this.sessionKey(e),s)}setItem(e,s){return super.setItem(this.sessionKey(e),s)}removeItem(e){return super.removeItem(this.sessionKey(e))}clear(){return super.clear(this.sessionKey(""))}sessionKey(e){const s=[e];return this.settings.sessionNative?e:(this.settings.sessionPrefix&&s.unshift(this.settings.sessionPrefix),s.join("."))}checkSession(){return!!this.superCookie.getItem(this.settings.sessionCookieName)}killSession(){this.superCookie.setItem(this.settings.sessionCookieName,"YES",{domain:window.location.hostname,path:"/",maxAge:null,expires:null,secure:!1}),this.clear()}},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@jaysalvat/super-storage",
"version": "1.1.1",
"version": "1.1.2",
"description": "Cookie, localStorage and sessionStorage javascript helpers",

@@ -14,6 +14,7 @@ "main": "./build/super-storage.umd.js",

"prebuild": "rm -fr ./build",
"release": "npm version patch & npm publish",
"release:patch": "npm version patch & npm publish",
"release:minor": "npm version minor & npm publish",
"release:major": "npm version major & npm publish"
"release": "npm version patch",
"release:patch": "npm version patch",
"release:minor": "npm version minor",
"release:major": "npm version major",
"postrelease": "npm run build && npm publish"
},

@@ -20,0 +21,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc