{"_id":"@bisham/dom-storage-sync","_rev":"4-15b759f8837a337d344a340e07decf6b","name":"@bisham/dom-storage-sync","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"@bisham/dom-storage-sync","version":"0.0.1","keywords":["dom","storage","cookie","sync","storage sync"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/dom-storage-sync@0.0.1","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"dist":{"shasum":"199072cfc9c7c33417271f86fb2c469ca6c075bc","tarball":"https://registry.npmjs.org/@bisham/dom-storage-sync/-/dom-storage-sync-0.0.1.tgz","fileCount":3,"integrity":"sha512-6/VDodzNGZKZjPrHCssLcnEgcJnDkD4kgkPipkBOMcX5D2MYCLHIr++pkRfCJ7h46O2Kr+aHzx0u9BQYNNx2jw==","signatures":[{"sig":"MEQCICNp2EzyU47GLgJDVyHyWTqWoRmYxcP8IrJ1kmHjIpWMAiA6iqdf7E2NgXop/MOVo2JQP5aB/Vzk1qUWmaW8uvmsSA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2601},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a369d0bfe3fdc0bc7409f14f39f5daefd58220be","scripts":{"build":"rollup -c"},"_npmUser":{"name":"bishamkunwor","actor":{"name":"bishamkunwor","type":"user","email":"novelian.nova@gmail.com"},"email":"novelian.nova@gmail.com"},"repository":{"url":"git+https://github.com/BishamKunwor/BishamKunwor.git","type":"git","directory":"packages/dom-storage-sync"},"_npmVersion":"10.8.2","description":"A simple Js function that subscribes to storage change events i.e, localStorage, sessionStorage and Cookie Storage","directories":{},"_nodeVersion":"20.19.1","_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.44.2","typescript":"^5.8.3","@types/node":"^24.0.10","rollup-plugin-dts":"^6.2.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.4","@rollup/plugin-node-resolve":"^16.0.1"},"_npmOperationalInternal":{"tmp":"tmp/dom-storage-sync_0.0.1_1751872872878_0.2024129965878001","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@bisham/dom-storage-sync","version":"0.0.2","keywords":["dom","storage","cookie","sync","storage sync"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/dom-storage-sync@0.0.2","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"dist":{"shasum":"e2989781954b6841921f86d3738d6443d71aef4c","tarball":"https://registry.npmjs.org/@bisham/dom-storage-sync/-/dom-storage-sync-0.0.2.tgz","fileCount":3,"integrity":"sha512-FZOpExMItuGw8mPRZ2aqjAH/oSRY+VmaLL0I3fYx34tE8ZynCUuJvgiE7mBPl2yxJrwh9n1vDrArVBH28tN6YQ==","signatures":[{"sig":"MEQCID/aKPAUUIcyZmLd21sQQdAGwSRPojPLnlyA2EqyZqhmAiAWOd0kwtCGR70wHP40MxNUOqZbmSWYpau3WCOJVip7pw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2988},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"4b3c8cfb1b4b1e450712b3b238a6a3b62f40b422","scripts":{"build":"rollup -c","watch":"rollup -c -w"},"_npmUser":{"name":"bishamkunwor","actor":{"name":"bishamkunwor","type":"user","email":"novelian.nova@gmail.com"},"email":"novelian.nova@gmail.com"},"repository":{"url":"git+https://github.com/BishamKunwor/BishamKunwor.git","type":"git","directory":"packages/dom-storage-sync"},"_npmVersion":"10.8.2","description":"A simple Js function that subscribes to storage change events i.e, localStorage, sessionStorage and Cookie Storage","directories":{},"_nodeVersion":"20.19.1","_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.44.2","typescript":"^5.8.3","@types/node":"^24.0.10","rollup-plugin-dts":"^6.2.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.4","@rollup/plugin-node-resolve":"^16.0.1"},"_npmOperationalInternal":{"tmp":"tmp/dom-storage-sync_0.0.2_1751887978601_0.007983524311065526","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@bisham/dom-storage-sync","version":"0.0.3","keywords":["dom","storage","cookie","sync","storage sync"],"author":{"url":"https://bishamkunwor.com.np","name":"Bisham Kunwor","email":"novelian.nova@gmail.com"},"license":"MIT","_id":"@bisham/dom-storage-sync@0.0.3","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"dist":{"shasum":"fb61f97917be5070efe2c44962f0cf8e886a4cb6","tarball":"https://registry.npmjs.org/@bisham/dom-storage-sync/-/dom-storage-sync-0.0.3.tgz","fileCount":4,"integrity":"sha512-Sg3/jKJr5bVwmfYbnoC0C/f1zyQNPkcrMhngBn35lOvwdyjvyBMKKQbXxzWmkG/gKbcRdsOFKfJm0qzwehmGnQ==","signatures":[{"sig":"MEUCIGv6Fnj1YjVu7iull2lKT+fDeO6oj50fwzCkK80TUIzZAiEAtEvboz+DUq1CtRutVP95sQyP7i/PlI2Za2lsg0bvda0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6137},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"4115820aed1dc816e2cc510d325722fba7c52c58","scripts":{"build":"rollup -c","watch":"rollup -c -w"},"_npmUser":{"name":"bishamkunwor","actor":{"name":"bishamkunwor","type":"user","email":"novelian.nova@gmail.com"},"email":"novelian.nova@gmail.com"},"repository":{"url":"git+https://github.com/BishamKunwor/BishamKunwor.git","type":"git","directory":"packages/dom-storage-sync"},"_npmVersion":"10.8.2","description":"A simple Js function that subscribes to storage change events i.e, localStorage, sessionStorage and Cookie Storage","directories":{},"_nodeVersion":"20.19.1","_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.44.2","typescript":"^5.8.3","@types/node":"^24.0.10","rollup-plugin-dts":"^6.2.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.4","@rollup/plugin-node-resolve":"^16.0.1"},"_npmOperationalInternal":{"tmp":"tmp/dom-storage-sync_0.0.3_1751888847782_0.38831419519708854","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@bisham/dom-storage-sync","version":"0.0.4","main":"dist/index.js","types":"dist/index.d.ts","author":{"name":"Bisham Kunwor","email":"novelian.nova@gmail.com","url":"https://bishamkunwor.com.np"},"repository":{"type":"git","url":"git+https://github.com/BishamKunwor/BishamKunwor.git","directory":"packages/dom-storage-sync"},"keywords":["dom","storage","cookie","sync","storage sync"],"license":"MIT","description":"A simple Js function that subscribes to storage change events i.e, localStorage, sessionStorage and Cookie Storage","devDependencies":{"@rollup/plugin-node-resolve":"^16.0.1","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.4","@types/node":"^24.0.10","rollup":"^4.44.2","rollup-plugin-dts":"^6.2.1","tslib":"^2.8.1","typescript":"^5.8.3"},"dependencies":{"cookie-store":"^3.0.0"},"scripts":{"build":"rollup -c","watch":"rollup -c -w"},"_id":"@bisham/dom-storage-sync@0.0.4","bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","_integrity":"sha512-u8g2E1WosTv6nqT2fauwsjFrnVA0bteHnVadcfpWSGE6PPvKDCvTPgLU5NBm2i35AKGuZovMZHsr0f66LKxuEA==","_resolved":"C:\\Users\\NOVEL\\AppData\\Local\\Temp\\39343f23028913bc6498cc973ca646a6\\bisham-dom-storage-sync-0.0.4.tgz","_from":"file:bisham-dom-storage-sync-0.0.4.tgz","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-u8g2E1WosTv6nqT2fauwsjFrnVA0bteHnVadcfpWSGE6PPvKDCvTPgLU5NBm2i35AKGuZovMZHsr0f66LKxuEA==","shasum":"a1bc870754aebcc992bbba075b5c51c9f46416d7","tarball":"https://registry.npmjs.org/@bisham/dom-storage-sync/-/dom-storage-sync-0.0.4.tgz","fileCount":5,"unpackedSize":10116,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDw4/3rbeLeU0ItYCCe2nZPruxxdgM8aSNNIIVAAAeMlAiAm/j/oo+C8CwTv2FEaClACxjedeghj3egHYvvl7lW3qA=="}]},"_npmUser":{"name":"bishamkunwor","email":"novelian.nova@gmail.com"},"directories":{},"maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dom-storage-sync_0.0.4_1766678396932_0.26115122586805417"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-07T07:21:12.753Z","modified":"2025-12-25T15:59:57.299Z","0.0.1":"2025-07-07T07:21:13.042Z","0.0.2":"2025-07-07T11:32:58.764Z","0.0.3":"2025-07-07T11:47:27.970Z","0.0.4":"2025-12-25T15:59:57.078Z"},"bugs":{"url":"https://github.com/BishamKunwor/BishamKunwor/issues"},"author":{"name":"Bisham Kunwor","email":"novelian.nova@gmail.com","url":"https://bishamkunwor.com.np"},"license":"MIT","homepage":"https://github.com/BishamKunwor/BishamKunwor#readme","keywords":["dom","storage","cookie","sync","storage sync"],"repository":{"type":"git","url":"git+https://github.com/BishamKunwor/BishamKunwor.git","directory":"packages/dom-storage-sync"},"description":"A simple Js function that subscribes to storage change events i.e, localStorage, sessionStorage and Cookie Storage","maintainers":[{"name":"bishamkunwor","email":"novelian.nova@gmail.com"}],"readme":"A lightweight JavaScript/TypeScript utility for subscribing to changes in browser storage mechanisms: **localStorage**, **sessionStorage**, and **cookieStorage** using the `cookieStore` API. Useful for real-time sync of storage data across browser tabs or app components.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 📦 Subscribe to **localStorage**, **sessionStorage**, or **cookieStorage**\r\n- 🔄 Automatically update subscribers on `localStorage`, `sessionStorage` and `cookieStore` mutations\r\n- 🔒 Type-safe with TypeScript support\r\n- 🌐 Multi-tab change detection for `localStorage` and `sessionStorage`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @bisham/dom-storage-sync\r\n# or\r\nyarn add @bisham/dom-storage-sync\r\n```\r\n\r\n---\r\n\r\n## Usage\r\n\r\n### 1. Import and Use\r\n\r\n```ts\r\nimport { getStorageSubscription } from \"@bisham/dom-storage-sync\";\r\n\r\nconst localStorageSub = getStorageSubscription(\"localStorage\");\r\n\r\nconst unsubscribe = localStorageSub.subscribe(() => {\r\n  console.log(\"Local Storage changed:\", localStorageSub.getSnapshot());\r\n});\r\n\r\n// Later, if needed\r\nunsubscribe();\r\n```\r\n\r\n```ts\r\nimport { getStorageSubscription } from \"@bisham/dom-storage-sync\";\r\n\r\nconst sessionStorageSub = getStorageSubscription(\"sessionStorage\");\r\n\r\nconst unsubscribe = sessionStorageSub.subscribe(() => {\r\n  console.log(\"Session Storage changed:\", sessionStorageSub.getSnapshot());\r\n});\r\n\r\n// Later, if needed\r\nunsubscribe();\r\n```\r\n\r\n### 2. Available Storage Types\r\n\r\n- `'localStorage'`\r\n- `'sessionStorage'`\r\n- `'cookieStorage'`\r\n\r\n### 3. Example with Cookies\r\n\r\n```ts\r\nconst cookieStorageSub = getStorageSubscription(\"cookieStorage\");\r\n\r\nconst unsubscribe = cookieStorageSub.subscribe(() => {\r\n  console.log(\"Cookies updated:\", cookieStorageSub.getSnapshot());\r\n});\r\n```\r\n\r\n---\r\n\r\n## API\r\n\r\n### `getStorageSubscription(storageType)`\r\n\r\nReturns an object that allows you to **subscribe** to storage changes and **get current snapshot**.\r\n\r\n#### Parameters\r\n\r\n- `storageType`: `\"localStorage\" | \"sessionStorage\" | \"cookieStorage\"`\r\n\r\n#### Returns\r\n\r\n```ts\r\n{\r\n  getSnapshot: () => Record<string, string | null> | Map<string, CookieInit>,\r\n  subscribe: (callback: () => void) => () => void\r\n}\r\n```\r\n\r\n- `getSnapshot()` returns current key-value pairs of the selected storage.\r\n- `subscribe(callback)` triggers the callback when the storage updates. Returns an `unsubscribe` function.\r\n\r\n---\r\n\r\n## ⚠️ Notes\r\n\r\n- This utility is intended for **client-side** use only.\r\n  > 💡 Make sure your app runs in a **secure context (HTTPS)** for cookieStore to work.\r\n\r\n---\r\n\r\n## 📄 License\r\n\r\nMIT © [Bisham Kunwor](https://bishamkunwor.com.np)\r\n\r\n---\r\n\r\n## 🧑‍💻 Author\r\n\r\n- **Name**: Bisham Kunwor\r\n- **Email**: [novelian.nova@gmail.com](mailto:novelian.nova@gmail.com)\r\n- **GitHub**: [@BishamKunwor](https://github.com/BishamKunwor)\r\n- **Website**: [bishamkunwor.com.np](https://bishamkunwor.com.np)\r\n\r\n---\r\n","readmeFilename":"README.md"}