@analytics/storage-utils
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.2.4](https://github.com/DavidWells/analytics/compare/@analytics/storage-utils@0.2.3...@analytics/storage-utils@0.2.4) (2020-07-14) | ||
**Note:** Version bump only for package @analytics/storage-utils | ||
## [0.2.3](https://github.com/DavidWells/analytics/compare/@analytics/storage-utils@0.2.2...@analytics/storage-utils@0.2.3) (2020-04-16) | ||
@@ -8,0 +16,0 @@ |
@@ -118,20 +118,4 @@ var analyticsUtilStorage = (function (exports) { | ||
/* global self globalThis */ | ||
function getGlobalThis() { | ||
if (typeof globalThis !== 'undefined') return globalThis; | ||
if (typeof global !== 'undefined') return global; | ||
if (typeof self !== 'undefined') return self; | ||
/* eslint-disable-line no-restricted-globals */ | ||
var globalContext = (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) === 'object' && global.global === global && global || undefined; | ||
if (typeof window !== 'undefined') return window; | ||
if (typeof this !== 'undefined') return this; | ||
return {}; // should never happen | ||
} | ||
/* tinier from https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js | ||
const context = (typeof self === 'object' && self.self === self && self) || // eslint-disable-line | ||
(typeof global === 'object' && global.global === global && global) || | ||
this | ||
export default context | ||
*/ | ||
var LOCAL_STORAGE = 'localStorage'; | ||
@@ -174,3 +158,3 @@ var COOKIE = 'cookie'; | ||
return getGlobalThis[key] || null; | ||
return globalContext[key] || null; | ||
} | ||
@@ -182,3 +166,3 @@ | ||
localStorage: parse(localStorage.getItem(key)), | ||
global: getGlobalThis[key] || null | ||
global: globalContext[key] || null | ||
}; | ||
@@ -231,4 +215,4 @@ } | ||
var oldValue = getGlobalThis[key]; | ||
getGlobalThis[key] = value; | ||
var oldValue = globalContext[key]; | ||
globalContext[key] = value; | ||
return { | ||
@@ -264,3 +248,3 @@ value: value, | ||
getGlobalThis[key] = null; | ||
globalContext[key] = undefined; | ||
return GLOBAL; | ||
@@ -292,2 +276,3 @@ } | ||
exports.removeCookie = removeCookie; | ||
exports.globalContext = globalContext; | ||
exports.hasLocalStorageSupport = hasLocalStorage; | ||
@@ -294,0 +279,0 @@ exports.hasCookieSupport = hasCookieSupport; |
@@ -1,1 +0,1 @@ | ||
var analyticsUtilStorage=function(e){"use strict";function o(e,t,o,r,n,a){if("undefined"!=typeof window)return 1<arguments.length?document.cookie=e+"="+encodeURIComponent(t)+(o?"; expires="+new Date(+new Date+1e3*o).toUTCString()+(r?"; path="+r:"")+(n?"; domain="+n:"")+(a?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}function t(){try{var e="_c_";o(e,"1");var t=-1!==document.cookie.indexOf(e);return o(e,"",-1),t}catch(e){return!1}}var u=o,f=o;function r(e){return o(e,"",-1)}function n(){try{if("undefined"==typeof localStorage||"undefined"==typeof JSON)return!1;localStorage.setItem("_t_","1"),localStorage.removeItem("_t_")}catch(e){return!1}return!0}function a(e){return(a="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 c(t){var o;try{void 0===(o=JSON.parse(t))&&(o=t),"true"===o&&(o=!0),"false"===o&&(o=!1),parseFloat(o)===o&&"object"!==a(o)&&(o=parseFloat(o))}catch(e){o=t}return o}function d(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==this?this:{}}var g="localStorage",m="cookie",v="global",l=n(),i=t();function s(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return null;var o,r=S(t);if("all"===r)return{cookie:c(u(o=e)),localStorage:c(localStorage.getItem(o)),global:d[o]||null};if(I(r)){var n=localStorage.getItem(e);if(n||r===g)return c(n)}if(b(r)){var a=u(e);if(a||r===m)return c(a)}return d[e]||null}function p(e,t){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return!1;var r=S(o),n=JSON.stringify(t);if(I(r)){var a=c(localStorage.getItem(e));return localStorage.setItem(e,n),{value:t,oldValue:a,location:g}}if(b(r)){var l=c(u(e));return f(e,n),{value:t,oldValue:l,location:m}}var i=d[e];return{value:d[e]=t,oldValue:i,location:v}}function y(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return!1;var o=S(t);return I(o)?(localStorage.removeItem(e),g):b(o)?(r(e),m):(d[e]=null,v)}function S(e){return"string"==typeof e?e:e.storage}function I(e){return l&&(!e||e===g)}function b(e){return i&&(!e||e===m)}var h={getItem:s,setItem:p,removeItem:y};return e.getItem=s,e.setItem=p,e.removeItem=y,e.getCookie=u,e.setCookie=f,e.removeCookie=r,e.hasLocalStorageSupport=n,e.hasCookieSupport=t,e.default=h,e}({}); | ||
var analyticsUtilStorage=function(e){"use strict";function o(e,t,o,r,n,l){if("undefined"!=typeof window)return 1<arguments.length?document.cookie=e+"="+encodeURIComponent(t)+(o?"; expires="+new Date(+new Date+1e3*o).toUTCString()+(r?"; path="+r:"")+(n?"; domain="+n:"")+(l?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}function t(){try{var e="_c_";o(e,"1");var t=-1!==document.cookie.indexOf(e);return o(e,"",-1),t}catch(e){return!1}}var i=o,f=o;function r(e){return o(e,"",-1)}function n(){try{if("undefined"==typeof localStorage||"undefined"==typeof JSON)return!1;localStorage.setItem("_t_","1"),localStorage.removeItem("_t_")}catch(e){return!1}return!0}function l(e){return(l="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 c(t){var o;try{void 0===(o=JSON.parse(t))&&(o=t),"true"===o&&(o=!0),"false"===o&&(o=!1),parseFloat(o)===o&&"object"!==l(o)&&(o=parseFloat(o))}catch(e){o=t}return o}var g="object"===("undefined"==typeof self?"undefined":l(self))&&self.self===self&&self||"object"===("undefined"==typeof global?"undefined":l(global))&&global.global===global&&global||void 0,d="localStorage",v="cookie",m="global",a=n(),u=t();function s(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return null;var o,r=S(t);if("all"===r)return{cookie:c(i(o=e)),localStorage:c(localStorage.getItem(o)),global:g[o]||null};if(b(r)){var n=localStorage.getItem(e);if(n||r===d)return c(n)}if(I(r)){var l=i(e);if(l||r===v)return c(l)}return g[e]||null}function p(e,t){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return!1;var r=S(o),n=JSON.stringify(t);if(b(r)){var l=c(localStorage.getItem(e));return localStorage.setItem(e,n),{value:t,oldValue:l,location:d}}if(I(r)){var a=c(i(e));return f(e,n),{value:t,oldValue:a,location:v}}var u=g[e];return{value:g[e]=t,oldValue:u,location:m}}function y(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return!1;var o=S(t);return b(o)?(localStorage.removeItem(e),d):I(o)?(r(e),v):(g[e]=void 0,m)}function S(e){return"string"==typeof e?e:e.storage}function b(e){return a&&(!e||e===d)}function I(e){return u&&(!e||e===v)}var h={getItem:s,setItem:p,removeItem:y};return e.getItem=s,e.setItem=p,e.removeItem=y,e.getCookie=i,e.setCookie=f,e.removeCookie=r,e.globalContext=g,e.hasLocalStorageSupport=n,e.hasCookieSupport=t,e.default=h,e}({}); |
@@ -66,20 +66,4 @@ 'use strict'; | ||
/* global self globalThis */ | ||
function getGlobalThis() { | ||
if (typeof globalThis !== 'undefined') return globalThis; | ||
if (typeof global !== 'undefined') return global; | ||
if (typeof self !== 'undefined') return self; | ||
/* eslint-disable-line no-restricted-globals */ | ||
var globalContext = (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) === 'object' && global.global === global && global || undefined; | ||
if (typeof window !== 'undefined') return window; | ||
if (typeof this !== 'undefined') return this; | ||
return {}; // should never happen | ||
} | ||
/* tinier from https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js | ||
const context = (typeof self === 'object' && self.self === self && self) || // eslint-disable-line | ||
(typeof global === 'object' && global.global === global && global) || | ||
this | ||
export default context | ||
*/ | ||
var LOCAL_STORAGE = 'localStorage'; | ||
@@ -122,3 +106,3 @@ var COOKIE = 'cookie'; | ||
return getGlobalThis[key] || null; | ||
return globalContext[key] || null; | ||
} | ||
@@ -130,3 +114,3 @@ | ||
localStorage: parse(localStorage.getItem(key)), | ||
global: getGlobalThis[key] || null | ||
global: globalContext[key] || null | ||
}; | ||
@@ -179,4 +163,4 @@ } | ||
var oldValue = getGlobalThis[key]; | ||
getGlobalThis[key] = value; | ||
var oldValue = globalContext[key]; | ||
globalContext[key] = value; | ||
return { | ||
@@ -212,3 +196,3 @@ value: value, | ||
getGlobalThis[key] = null; | ||
globalContext[key] = undefined; | ||
return GLOBAL; | ||
@@ -241,3 +225,4 @@ } | ||
exports.removeItem = removeItem; | ||
exports.globalContext = globalContext; | ||
exports.hasLocalStorageSupport = hasLocalStorage; | ||
exports.default = index; |
@@ -63,20 +63,4 @@ import { hasCookieSupport, getCookie, setCookie, removeCookie } from '@analytics/cookie-utils'; | ||
/* global self globalThis */ | ||
function getGlobalThis() { | ||
if (typeof globalThis !== 'undefined') return globalThis; | ||
if (typeof global !== 'undefined') return global; | ||
if (typeof self !== 'undefined') return self; | ||
/* eslint-disable-line no-restricted-globals */ | ||
var globalContext = (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) === 'object' && global.global === global && global || undefined; | ||
if (typeof window !== 'undefined') return window; | ||
if (typeof this !== 'undefined') return this; | ||
return {}; // should never happen | ||
} | ||
/* tinier from https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js | ||
const context = (typeof self === 'object' && self.self === self && self) || // eslint-disable-line | ||
(typeof global === 'object' && global.global === global && global) || | ||
this | ||
export default context | ||
*/ | ||
var LOCAL_STORAGE = 'localStorage'; | ||
@@ -119,3 +103,3 @@ var COOKIE = 'cookie'; | ||
return getGlobalThis[key] || null; | ||
return globalContext[key] || null; | ||
} | ||
@@ -127,3 +111,3 @@ | ||
localStorage: parse(localStorage.getItem(key)), | ||
global: getGlobalThis[key] || null | ||
global: globalContext[key] || null | ||
}; | ||
@@ -176,4 +160,4 @@ } | ||
var oldValue = getGlobalThis[key]; | ||
getGlobalThis[key] = value; | ||
var oldValue = globalContext[key]; | ||
globalContext[key] = value; | ||
return { | ||
@@ -209,3 +193,3 @@ value: value, | ||
getGlobalThis[key] = null; | ||
globalContext[key] = undefined; | ||
return GLOBAL; | ||
@@ -232,2 +216,2 @@ } | ||
export default index; | ||
export { getItem, setItem, removeItem, hasLocalStorage as hasLocalStorageSupport }; | ||
export { getItem, setItem, removeItem, globalContext, hasLocalStorage as hasLocalStorageSupport }; |
@@ -67,20 +67,4 @@ 'use strict'; | ||
/* global self globalThis */ | ||
function getGlobalThis() { | ||
if (typeof globalThis !== 'undefined') return globalThis; | ||
if (typeof global !== 'undefined') return global; | ||
if (typeof self !== 'undefined') return self; | ||
/* eslint-disable-line no-restricted-globals */ | ||
var globalContext = (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) === 'object' && global.global === global && global || undefined; | ||
if (typeof window !== 'undefined') return window; | ||
if (typeof this !== 'undefined') return this; | ||
return {}; // should never happen | ||
} | ||
/* tinier from https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js | ||
const context = (typeof self === 'object' && self.self === self && self) || // eslint-disable-line | ||
(typeof global === 'object' && global.global === global && global) || | ||
this | ||
export default context | ||
*/ | ||
var LOCAL_STORAGE = 'localStorage'; | ||
@@ -123,3 +107,3 @@ var COOKIE = 'cookie'; | ||
return getGlobalThis[key] || null; | ||
return globalContext[key] || null; | ||
} | ||
@@ -131,3 +115,3 @@ | ||
localStorage: parse(localStorage.getItem(key)), | ||
global: getGlobalThis[key] || null | ||
global: globalContext[key] || null | ||
}; | ||
@@ -180,4 +164,4 @@ } | ||
var oldValue = getGlobalThis[key]; | ||
getGlobalThis[key] = value; | ||
var oldValue = globalContext[key]; | ||
globalContext[key] = value; | ||
return { | ||
@@ -213,3 +197,3 @@ value: value, | ||
getGlobalThis[key] = null; | ||
globalContext[key] = undefined; | ||
return GLOBAL; | ||
@@ -242,3 +226,4 @@ } | ||
exports.removeItem = removeItem; | ||
exports.globalContext = globalContext; | ||
exports.hasLocalStorageSupport = hasLocalStorage; | ||
exports.default = index; |
@@ -64,20 +64,4 @@ import { hasCookieSupport, getCookie, setCookie, removeCookie } from '@analytics/cookie-utils'; | ||
/* global self globalThis */ | ||
function getGlobalThis() { | ||
if (typeof globalThis !== 'undefined') return globalThis; | ||
if (typeof global !== 'undefined') return global; | ||
if (typeof self !== 'undefined') return self; | ||
/* eslint-disable-line no-restricted-globals */ | ||
var globalContext = (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' && self.self === self && self || (typeof global === "undefined" ? "undefined" : _typeof(global)) === 'object' && global.global === global && global || undefined; | ||
if (typeof window !== 'undefined') return window; | ||
if (typeof this !== 'undefined') return this; | ||
return {}; // should never happen | ||
} | ||
/* tinier from https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js | ||
const context = (typeof self === 'object' && self.self === self && self) || // eslint-disable-line | ||
(typeof global === 'object' && global.global === global && global) || | ||
this | ||
export default context | ||
*/ | ||
var LOCAL_STORAGE = 'localStorage'; | ||
@@ -120,3 +104,3 @@ var COOKIE = 'cookie'; | ||
return getGlobalThis[key] || null; | ||
return globalContext[key] || null; | ||
} | ||
@@ -128,3 +112,3 @@ | ||
localStorage: parse(localStorage.getItem(key)), | ||
global: getGlobalThis[key] || null | ||
global: globalContext[key] || null | ||
}; | ||
@@ -177,4 +161,4 @@ } | ||
var oldValue = getGlobalThis[key]; | ||
getGlobalThis[key] = value; | ||
var oldValue = globalContext[key]; | ||
globalContext[key] = value; | ||
return { | ||
@@ -210,3 +194,3 @@ value: value, | ||
getGlobalThis[key] = null; | ||
globalContext[key] = undefined; | ||
return GLOBAL; | ||
@@ -233,2 +217,2 @@ } | ||
export default index; | ||
export { getItem, setItem, removeItem, hasLocalStorage as hasLocalStorageSupport }; | ||
export { getItem, setItem, removeItem, globalContext, hasLocalStorage as hasLocalStorageSupport }; |
{ | ||
"name": "@analytics/storage-utils", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Storage utilities for saving values in browser", | ||
@@ -51,3 +51,3 @@ "author": "David Wells", | ||
}, | ||
"gitHead": "e0a23c74d7bb6848631b51413a6443025e8b0cef" | ||
"gitHead": "6235efa2a3431d781a29a91c82e4aeb2b2aec1d9" | ||
} |
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
40555
915