{"id":49701,"library":"web-storage-es6","title":"Web Storage ES6","description":"web-storage-es6 is a lightweight ES6 library that provides an abstraction layer over the HTML5 web storage APIs (localStorage and sessionStorage) plus an in-memory global storage. Version 1.2.0 is the current stable release. It offers namespace isolation, batch operations (populate/append), and fallback defaults. Unlike raw storage APIs, it serializes objects automatically and prevents common pitfalls like repetitive writes. The library has minimal overhead and no external dependencies, making it suitable for browser-based projects where a simple, predictable storage wrapper is needed over alternatives like localForage or store.js.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/alanzhaonys/web-storage-es6","tags":["javascript","web","storage","localStorage","sessionStorage"],"install":[{"cmd":"npm install web-storage-es6","lang":"bash","label":"npm"},{"cmd":"yarn add web-storage-es6","lang":"bash","label":"yarn"},{"cmd":"pnpm add web-storage-es6","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library exports a single class as default export. Named import will result in undefined.","wrong":"import { WebStorageES6 } from 'web-storage-es6'","symbol":"default","correct":"import WebStorageES6 from 'web-storage-es6'"},{"note":"CommonJS require returns the class directly; destructuring is incorrect.","wrong":"const { WebStorageES6 } = require('web-storage-es6')","symbol":"require","correct":"const WebStorageES6 = require('web-storage-es6')"},{"note":"The storage type must be the string 'Local', 'Session', or 'Global' (case-sensitive).","wrong":"const local = new WebStorageES6('localStorage')","symbol":"Storage instances","correct":"const local = new WebStorageES6('Local')"}],"quickstart":{"code":"import WebStorageES6 from 'web-storage-es6';\n\n// Create a local storage with 'default' namespace\nconst localStorage = new WebStorageES6('Local');\n\n// Create a session storage\nconst sessionStorage = new WebStorageES6('Session');\n\n// Create a global storage with a custom namespace\nconst globalStorage = new WebStorageES6('Global', 'custom');\n\n// Set values\nlocalStorage.put('key1', 'value1');\n\n// Get with default\nconst value = localStorage.get('key1', 'default');\n\n// Check existence\nif (localStorage.has('key1')) {\n  console.log('key1 exists');\n}\n\n// Bulk populate\nlocalStorage.populate({ a: 1, b: 2 });\n\n// Append\nlocalStorage.append({ c: 3 });\n\n// Remove\nlocalStorage.forget('key1');\n\n// Clear all namespaced data\nlocalStorage.flush();\n\n// Pull (get and remove)\nconst pulled = localStorage.pull('a', 'nope');\n\n// Get all data\nconst all = localStorage.all();\nconsole.log(all); // { b: 2, c: 3 }","lang":"typescript","description":"Demonstrates all major storage operations: create instances of Local, Session, Global storage; set, get, check, populate, append, forget, flush, pull, and retrieve all data."},"warnings":[{"fix":"Use the exact strings: 'Local', 'Session', 'Global'.","message":"Storage type names are case-sensitive and must be exactly 'Local', 'Session', or 'Global'. Typing 'localStorage' or 'session' will fail silently or throw an error.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not rely on underscore-prefixed methods; use public API only.","message":"The package uses internal methods like _setData and _getData which are marked protected and may change without notice.","severity":"deprecated","affected_versions":"all"},{"fix":"Use 'Global' only for temporary single-page data. Consider 'Local' or 'Session' for persistence.","message":"The 'Global' storage stores data on the global window object under the namespace key. It does not survive page reloads and memory is not cleared unless flushed.","severity":"gotcha","affected_versions":"all"},{"fix":"Only store JSON-serializable data (strings, numbers, objects, arrays, booleans, null).","message":"Values are serialized via JSON.stringify and deserialized via JSON.parse. Non-JSON-serializable values (e.g., Functions, Symbols, circular references) will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a polyfill or transpile with Babel for IE11 and below.","message":"The library was originally written in ES6 and may require a polyfill for Object.assign or Promise in very old browsers.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.2.0':35 'abstract':16 'altern':92 'api':23,54 'automat':58 'base':81 'batch':45 'browser':80 'browser-bas':79 'common':61 'current':38 'default':50 'depend':74 'es6':3,7,11 'extern':73 'fallback':49 'global':32 'html5':20 'in-memori':29 'isol':44 'javascript':97 'layer':17 'librari':12,67 'lightweight':10 'like':63,93 'localforag':94 'localstorag':24,100 'make':75 'memori':31 'minim':69 'namespac':43 'need':90 'object':57 'offer':42 'oper':46 'overhead':70 'pitfal':62 'plus':27 'populate/append':47 'predict':86 'prevent':60 'project':82 'provid':14 'raw':52 'releas':40 'repetit':64 'serial':56 'sessionstorag':26,101 'simpl':85 'stabl':39 'storag':2,6,22,33,53,87,99 'store.js':96 'suitabl':77 'unlik':51 'version':34 'web':1,5,21,98 'web-storage-es6':4 'wrapper':88 'write':65","created_at":"2026-06-07T17:03:09.879234+00:00","updated_at":"2026-06-07T17:03:09.879234+00:00","problems":[{"fix":"Correct import: import WebStorageES6 from 'web-storage-es6' or const WebStorageES6 = require('web-storage-es6').","cause":"Wrong import pattern: using named import instead of default import, or destructuring require.","error":"TypeError: WebStorageES6 is not a constructor"},{"fix":"Use one of: 'Local', 'Session', 'Global'.","cause":"Passing an incorrect string for storage type, e.g., 'localStorage' instead of 'Local'.","error":"Error: Invalid storage type."},{"fix":"Create an instance first: const store = new WebStorageES6('Local'); then call store.get().","cause":"Calling methods on the class itself instead of an instance.","error":"TypeError: storage.get is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/alanzhaonys/web-storage-es6#readme","github":"https://github.com/alanzhaonys/web-storage-es6","docs":null,"changelog":null,"pypi":null,"npm":"web-storage-es6","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}