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

@wezz/store-manager

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wezz/store-manager - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

203

build/index.js
/*!
*
* @wezz/store-manager v0.0.12
* @wezz/store-manager v0.0.13
* https://github.com/wezz/StoreManager

@@ -12,3 +12,202 @@ *

*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.StoreManager=t():e.StoreManager=t()}(self,(function(){return(()=>{"use strict";var e={346:(e,t)=>{var o=function(){function e(e){void 0===e&&(e="cache"),this.storageTypes={permanent:"localStorage",temporary:"sessionStorage"},this.prefix=e}return e.prototype.getStorageMedium=function(e){void 0===e&&(e=!0);var t=e?this.storageTypes.permanent:this.storageTypes.temporary;return void 0!==window[t]?window[t]:null},e.prototype.Has=function(e){return void 0!==this.Get(this.prefix+"-"+e)},e.prototype.Get=function(e){var t=this.getStorageMedium(!1),o=this.getStorageMedium(!0),r=!1,i=null;if(t&&o){try{i=t.getItem(this.prefix+"-"+e),r=null!==(i=this.toJSONIfJSON(i))}catch(e){}if(!r)try{i=o.getItem(this.prefix+"-"+e),r=null!==(i=this.toJSONIfJSON(i))}catch(e){}}return i},e.prototype.toJSONIfJSON=function(e){return"string"!=typeof e||0!==e.indexOf("{")&&0!==e.indexOf("[")||(e=JSON.parse(e)),e},e.prototype.Save=function(e,t,o){void 0===o&&(o=!0),console.warn("StoreManager.Save is deprecated"),this.Set(e,t,o)},e.prototype.Set=function(e,t,o){void 0===o&&(o=!0);var r=this.getStorageMedium(o),i=!1;if(r){"object"==typeof t&&(t=JSON.stringify(t));try{r.setItem(this.prefix+"-"+e,t),i=!0}catch(e){console.error("Unable to save object",e)}}return i},e.prototype.Remove=function(e){var t=this.getStorageMedium(!0),o=this.getStorageMedium(!1);t&&t.removeItem(this.prefix+"-"+e),o&&o.removeItem(this.prefix+"-"+e)},e}();t.Z=o},138:(e,t,o)=>{o.r(t),o.d(t,{default:()=>r});const r=o(346).Z}},t={};function o(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,o),i.exports}return o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o(138)})()}));
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["StoreManager"] = factory();
else
root["StoreManager"] = factory();
})(typeof global !== 'undefined' ? global : this, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 346:
/***/ ((__unused_webpack_module, exports) => {
var __webpack_unused_export__;
/* # Storage Manager
This will gelp you fetch information from session and local storage.
## Usage
import StoreManager from '../modules/StoreManager';
const storage = new StoreManager("storename");
let valueobj = storage.Get("valuekey"); // Will return a JSOn object if possible
valueobj.prop = "updatedprop";
storage.Save("valuekey", valueobj, true);
The last boolean defines if the values should be stored past the current session
*/
__webpack_unused_export__ = ({ value: true });
var StoreManager = /** @class */ (function () {
function StoreManager(_prefix) {
if (_prefix === void 0) { _prefix = "cache"; }
this.storageTypes = {
permanent: "localStorage",
temporary: "sessionStorage",
};
this.prefix = _prefix;
}
StoreManager.prototype.getStorageMedium = function (permanent) {
if (permanent === void 0) { permanent = true; }
var storageType = permanent
? this.storageTypes.permanent
: this.storageTypes.temporary;
if (typeof window[storageType] !== "undefined") {
return window[storageType];
}
return null;
};
StoreManager.prototype.Has = function (key) {
return typeof this.Get("".concat(this.prefix, "-").concat(key)) !== "undefined";
};
StoreManager.prototype.Get = function (key) {
var tempStorage = this.getStorageMedium(false);
var permStorage = this.getStorageMedium(true);
var success = false;
var data = null;
if (tempStorage && permStorage) {
try {
data = tempStorage.getItem("".concat(this.prefix, "-").concat(key));
data = this.toJSONIfJSON(data);
success = data !== null;
}
catch (e) { }
if (!success) {
try {
data = permStorage.getItem("".concat(this.prefix, "-").concat(key));
data = this.toJSONIfJSON(data);
success = data !== null;
}
catch (e) { }
}
}
return data;
};
StoreManager.prototype.toJSONIfJSON = function (data) {
if (typeof data === "string" &&
(data.indexOf("{") === 0 || data.indexOf("[") === 0)) {
data = JSON.parse(data);
}
return data;
};
StoreManager.prototype.Save = function (key, data, permanent) {
if (permanent === void 0) { permanent = true; }
console.warn("StoreManager.Save is deprecated");
this.Set(key, data, permanent);
};
StoreManager.prototype.Set = function (key, data, permanent) {
if (permanent === void 0) { permanent = true; }
var storage = this.getStorageMedium(permanent);
var success = false;
if (storage) {
if (typeof data === "object") {
data = JSON.stringify(data);
}
try {
storage.setItem("".concat(this.prefix, "-").concat(key), data);
success = true;
}
catch (e) {
console.error("Unable to save object", e);
}
}
return success;
};
StoreManager.prototype.Remove = function (key) {
var permanentStore = this.getStorageMedium(true);
var sessionStorage = this.getStorageMedium(false);
if (permanentStore) {
permanentStore.removeItem("".concat(this.prefix, "-").concat(key));
}
if (sessionStorage) {
sessionStorage.removeItem("".concat(this.prefix, "-").concat(key));
}
};
return StoreManager;
}());
exports.Z = StoreManager;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _StoreManager_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(346);
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_StoreManager_ts__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z);
})();
/******/ return __webpack_exports__;
/******/ })()
;
});
//# sourceMappingURL=index.js.map

16

package.json
{
"name": "@wezz/store-manager",
"version": "0.0.12",
"version": "0.0.13",
"description": "A script to manage local and session storage",
"main": "build/index.js",
"module": "build/index.js",
"types": "build/StoreManager.d.ts",

@@ -34,3 +34,3 @@ "scripts": {

"@types/node": "^14.14.2",
"copy-webpack-plugin": "9.1.0",
"copy-webpack-plugin": "^9.1.0",
"css-loader": "^5.0.0",

@@ -41,13 +41,11 @@ "eslint": "^7.12.0",

"jest": "^26.6.1",
"prettier": "^2.1.2",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.0.1",
"ts-jest": "^26.4.2",
"ts-loader": "^8.0.7",
"typescript": "^4.0.3",
"ts-loader": "^9.4.2",
"typescript": "4.9.5",
"url-loader": "^4.1.1",
"webpack": "^5.2.0",
"webpack": "^5.75.0",
"webpack-cli": "^4.1.0"
},
"dependencies": {}
}
}

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