{"_id":"@bzzz/persist","_rev":"2-61e1063f3cd2d6c4dd111c7a8a8438cb","name":"@bzzz/persist","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.2":{"name":"@bzzz/persist","version":"1.0.2","keywords":["Storage","localStorage","sessionStorage"],"author":{"name":"Rhys Burnie"},"license":"ISC","_id":"@bzzz/persist@1.0.2","maintainers":[{"name":"rhys.burnie","email":"smart.boat3474@communication.quest"}],"homepage":"https://github.com/rhysburnie/persist#readme","bugs":{"url":"https://github.com/rhysburnie/persist/issues"},"dist":{"shasum":"14d4bf79b0128cb0fcb0cf698a5dda31de5150e0","tarball":"https://registry.npmjs.org/@bzzz/persist/-/persist-1.0.2.tgz","fileCount":6,"integrity":"sha512-4qJWu5AuYpFd4rOogPnt0PsOvf/QDLNenrLPj1HJ3DevRTBmSB4NdwyeqJtECSMU/v/zt3q6Ih+ZzRqwAD7UKg==","signatures":[{"sig":"MEUCIBOsAbqTe0Dr70uoFezQuWmrWsc0zNe6cn4lwPJYWzbrAiEA+VJDuZlatgHhNF/e9JoUHe383JkLgXzCjAYRolZDFIg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":92413},"main":"dist/persist-tool.umd.js","module":"dist/persist-tool.mjs","exports":{".":{"import":"./dist/persist-tool.mjs","require":"./dist/persist-tool.umd.js"}},"gitHead":"c3296ed1a7e80e9c8f61a870f3b6af2f57e7f762","scripts":{"dev":"vite","docs":"jsdoc2md --files src/*.js > DOCS.md","lint":"eslint","test":"vitest","bench":"vitest bench","build":"vite build","preview":"vite preview","prepublishOnly":"npm run build"},"_npmUser":{"name":"rhys.burnie","email":"smart.boat3474@communication.quest"},"repository":{"url":"git+https://github.com/rhysburnie/persist.git","type":"git"},"_npmVersion":"10.9.2","description":"A Storage wrapper with several utilities","directories":{},"_nodeVersion":"23.10.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^4.3.9","eslint":"^8.44.0","vitest":"^0.33.0","prettier":"^3.0.0","crypto-js":"^4.1.1","jsdoc-to-markdown":"^8.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-prettier":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/persist_1.0.2_1744245265336_0.17269655018403607","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@bzzz/persist","author":{"name":"Rhys Burnie"},"repository":{"type":"git","url":"git+https://github.com/rhysburnie/persist.git"},"description":"A Storage wrapper with several utilities","keywords":["Storage","localStorage","sessionStorage"],"license":"ISC","version":"1.0.3","main":"dist/persist.umd.js","module":"dist/persist.mjs","exports":{".":{"import":"./dist/persist.mjs","require":"./dist/persist.umd.js"}},"scripts":{"dev":"vite","build":"vite build","preview":"vite preview","test":"vitest","bench":"vitest bench","docs":"jsdoc2md --files src/*.js > DOCS.md","lint":"eslint","prepublishOnly":"npm run build"},"devDependencies":{"crypto-js":"^4.1.1","eslint":"^8.44.0","eslint-config-prettier":"^8.8.0","eslint-plugin-prettier":"^4.2.1","jsdoc-to-markdown":"^8.0.0","prettier":"^3.0.0","vite":"^4.3.9","vitest":"^0.33.0"},"_id":"@bzzz/persist@1.0.3","gitHead":"a9c70f76199b0eeb81098bc898e9fb69a9b6c110","bugs":{"url":"https://github.com/rhysburnie/persist/issues"},"homepage":"https://github.com/rhysburnie/persist#readme","_nodeVersion":"23.10.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-AeBjZdUIjfi/OIQL5oJ7aLNu6eBvhOxEq0lDAuxjiVaqlRvEePRx6oq2P547L1RQVtWC+oMkcWSQ84Oh3Ys9ug==","shasum":"f39870fdfb7706da9084a840004e3db1e5740a4c","tarball":"https://registry.npmjs.org/@bzzz/persist/-/persist-1.0.3.tgz","fileCount":6,"unpackedSize":92621,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGuN6w2jp69k7N+pVvNijukBajaFCylZGRNq7e0weWE9AiEA+NAGzUKAGDjJ8SR55ZJ32p2gGP7KeIKhorFneYx68gA="}]},"_npmUser":{"name":"rhys.burnie","email":"smart.boat3474@communication.quest"},"directories":{},"maintainers":[{"name":"rhys.burnie","email":"smart.boat3474@communication.quest"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/persist_1.0.3_1744593692160_0.9219553832976157"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-10T00:34:25.181Z","modified":"2025-04-14T01:21:32.595Z","1.0.2":"2025-04-10T00:34:25.549Z","1.0.3":"2025-04-14T01:21:32.373Z"},"bugs":{"url":"https://github.com/rhysburnie/persist/issues"},"author":{"name":"Rhys Burnie"},"license":"ISC","homepage":"https://github.com/rhysburnie/persist#readme","keywords":["Storage","localStorage","sessionStorage"],"repository":{"type":"git","url":"git+https://github.com/rhysburnie/persist.git"},"description":"A Storage wrapper with several utilities","maintainers":[{"name":"rhys.burnie","email":"smart.boat3474@communication.quest"}],"readme":"# Persist\n\n- [Rationale](#rationale)\n- [Example](#example)\n- [Documentation](./DOCS.md) generated documentation\n\nDevelopment\n\n- `npm test`\n- `npm run bench`\n\n## Rationale\n\nThis tool was created as a replacement in a project where multiple methodologies were being used to persist data.\n\nBased on the combined requirements the tool provides the following:\n\n- [x] automatically stringify / parse data\n- [x] optionally auto prefix and or suffix keys\n- [x] optionally provide mechanism to sync data changed between tabs\n- [x] optionally use obfuscation for the store values\n- [ ] (undecided) provide ability to define the storage\n      technically this already possible, however many alternates use\n      promises, so to fully support we will have to use async / await\n      no bit deal just not sure we need it at the mo.\n- [x] bactch calls\n      the existing project has a Persist utility that batched calls\n      with a debounce, this is due to calls being made frequently\n      in short timeframes.\n      ~~this would add more complexity to the code and I'm undecided\n      about it, and perhaps it should be the responsibility of the consumer.~~\n      extension class `PersistToolBatch`\n      ** Not sure if I'll keep batch version in future, it prod I didnt see any time non batch fail **\n- [x] provide a \"no opperation\" instance (more on that later)\n- [x] a way to `clear` that doesnt clear other persists\n\n## Example\n\n`import Persist from '@bzzz/persist'`\n\n**Legacy**\n`import { PersistTool } from '@bzzz/persist'`\n\nCreate an instance:\n\n`const persist = new Persist()`\n\nThis would give you an api that writes to `localStorage` with keys that match exactly what you provide.\nIn other words, if you were to create multiple instances of `new Persist()` they would all read/write the same key in storage.\n\nUse for global generic items.\n\n**Batch version**\n\nSame as normal except it has a `delay` option (default: 500ms)\n\n`const persist = new PersistToolBatch();` / `const persist = new PersistToolBatch({delay: 1000});`\n\nsetItem, getItem, removeItem work instantly writing to a store and the actual (setItem) persist to Storage is delayed on each call.\nThus after `delay` of the last setItem call all pendizng writes will be added to the Storage.\n\n### Prefix / Suffix\n\n**prefix**\n\n`const persist = new Persist({prefix: 'myPrefix'})`\n\nThis would give you an api that writes to `localStorage` and prefix the keys.\n\n`const fullKey = persist.setItem('test', 1) === 'myPrefixtest'`\n\nProvide a seperator:\n\n`const persist = new Persist({prefix: 'myPrefix', seperator: '_})`\n\n`const fullKey = persist.setItem('test', 1) === 'myPrefix_test'`\n\n**suffix**\n\n`const persist = new Persist({suffix: 'mySuffix', seperator: '_})`\n\n`const fullKey = persist.setItem('test', 1) === 'test_mySuffix'`\n\n**both**\n\n`const persist = new Persist({prefix: 'myPrefix', suffix: 'mySuffix', seperator: '_})`\n\n`const fullKey = persist.setItem('test', 1) === 'myPrefix_test_mySuffix'`\n\nTypically suffix is useful for cases where you may want to store items agains something like a unique user uid, but want the keys to be easy to read in the localStorage inspector.\n","readmeFilename":"README.md"}