{"id":48466,"library":"memorystorage","title":"memorystorage","description":"MemoryStorage is a JavaScript library (v0.12.0) that provides an in-memory implementation of the Web Storage API (localStorage/sessionStorage). It serves as a drop-in replacement for environments where the native Web Storage API is unavailable, such as older browsers or server-side Node.js. The library supports both isolated (namespaced) and shared storage instances, follows the W3C specification, and is distributed as a UMD module compatible with CommonJS, AMD, and ES modules. It is lightweight (~2KB minified), has no dependencies, and is maintained by the Download organization on GitHub.","status":"active","version":"0.12.0","language":"javascript","source_language":"en","source_url":"https://github.com/download/memorystorage","tags":["javascript","persistence","persistent objects","localStorage","Web Storage API"],"install":[{"cmd":"npm install memorystorage","lang":"bash","label":"npm"},{"cmd":"yarn add memorystorage","lang":"bash","label":"yarn"},{"cmd":"pnpm add memorystorage","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import. CommonJS require returns the constructor directly; destructuring fails.","wrong":"const { MemoryStorage } = require('memorystorage')","symbol":"MemoryStorage","correct":"import MemoryStorage from 'memorystorage'"},{"note":"CommonJS require works but note that the package exports a single function, not an object with a MemoryStorage property.","symbol":"MemoryStorage","correct":"const MemoryStorage = require('memorystorage')"},{"note":"AMD module usage for RequireJS.","symbol":"MemoryStorage","correct":"define(['memorystorage'], function(MemoryStorage) { ... })"}],"quickstart":{"code":"import MemoryStorage from 'memorystorage';\n\n// Create a globally shared storage instance\nconst store = MemoryStorage();\nstore.setItem('key', 'value');\nconsole.log(store.getItem('key')); // 'value'\n\n// Create an isolated storage instance with a namespace\nconst isolated = new MemoryStorage('my-app');\nconsole.log(isolated.length); // 0\n\n// All Web Storage API methods are supported:\nstore.removeItem('key');\nstore.clear();\nconsole.log(store.key(0)); // null","lang":"typescript","description":"Create MemoryStorage instances (shared or isolated) and demonstrate basic Web Storage API operations."},"warnings":[{"fix":"Use either 'new MemoryStorage()' or 'MemoryStorage()'.","message":"MemoryStorage can be called with or without 'new'. Both work.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not attempt to overwrite the 'id' property after construction.","message":"The 'id' property is immutable; assignment is silently ignored in non-strict mode.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2kb':79 'amd':72 'api':19,36,100 'browser':42 'commonj':71 'compat':69 'depend':83 'distribut':64 'download':89 'drop':26 'drop-in':25 'environ':30 'es':74 'follow':58 'github':92 'implement':14 'in-memori':11 'instanc':57 'isol':52 'javascript':5,93 'librari':6,49 'lightweight':78 'localstorag':97 'localstorage/sessionstorage':20 'maintain':86 'memori':13 'memorystorag':1,2 'minifi':80 'modul':68,75 'namespac':53 'nativ':33 'node.js':47 'object':96 'older':41 'organ':90 'persist':94,95 'provid':9 'replac':28 'serv':22 'server':45 'server-sid':44 'share':55 'side':46 'specif':61 'storag':18,35,56,99 'support':50 'umd':67 'unavail':38 'v0.12.0':7 'w3c':60 'web':17,34,98","created_at":"2026-06-07T16:56:47.661739+00:00","updated_at":"2026-06-07T16:56:47.661739+00:00","problems":[{"fix":"Use 'import MemoryStorage from 'memorystorage'' or 'const MemoryStorage = require('memorystorage')'.","cause":"Importing incorrectly (e.g., using named import instead of default).","error":"TypeError: MemoryStorage is not a constructor"},{"fix":"Ensure you use default import: 'import MemoryStorage from 'memorystorage''.","cause":"If MemoryStorage was imported as an object with a property named 'MemoryStorage', but it's directly the constructor.","error":"TypeError: store.setItem 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":"http://download.github.io/memorystorage","github":"https://github.com/download/memorystorage","docs":null,"changelog":null,"pypi":null,"npm":"memorystorage","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}}