{"_id":"@actualwave/weak-storage","_rev":"8-48c12a9d2ff39a39954470ca6b5de94d","name":"@actualwave/weak-storage","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.1":{"name":"@actualwave/weak-storage","version":"0.0.1","author":"","license":"MIT","_id":"@actualwave/weak-storage@0.0.1","maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"homepage":"https://github.com/burdiuz/js-weak-storage#readme","bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"dist":{"shasum":"655f21e409424fd5a4c73d2b9fe95b0902afb55e","tarball":"https://registry.npmjs.org/@actualwave/weak-storage/-/weak-storage-0.0.1.tgz","fileCount":7,"integrity":"sha512-5PDMQTbBa5/tJnVOuu5gVFyMKMe+QqdF9nFAqmyKk8OmmwzascbcH1nXxOO2TnxtCJU8QHnSn5beh9f/ZPV2jw==","signatures":[{"sig":"MEQCIAXYV5q2cwykz3gsQTxYaX1o4E4YBOocIJUkjGEf9X4tAiBsO+4Bf1fA6yxpVQxao/XernwjCfCbA+2onIRc5k+cng==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJerxViCRA9TVsSAnZWagAAGE0P/2CyfZEUtp5dSQOet6be\nRcGUE+UP3XrTB2VohgOcp+zYFDIOE14dW5DeCLnAsRhz/f2eAPSen9opDUGR\n5qt0+ZZS7dTTnWOuUCJulbLFAymsLgqoR6pDMe2i7Ki2Ca32OThE5cMIGw7b\n+7xxXrDSR9ncUNc3FzUwR394eUtqlU1Ut4xFv4dBRZke8kaPS36tcE/n9Hk2\n49Omb282KYM1iTz0Qimf450oj57b0s85burbu9dTRg9HU+/c6MXsYQQEo0zM\nzPwxST4gHAWEdZNgEGtJndCqMuNYK+pz9J1GQDNr6ekC/QPpoYA5+Q7DbeO5\nqUp6VLHBC2Edmru/Gq7sTtbQdU6Qo3kn26rZvsjkC0DW7y4eKDXvHd566gW1\nA1BnQb+/CE56HPGSTRXBgiSuBxPkxemfLBBdWUg5JK10A8qvUytdkjlMvscO\nIeWr77ws6SUtB/r9EFs0UI+h2ywK3gkrWVuzkT4ATXb0yjv+6detMoOv27x2\nr/htXwK3sQqG94RlK1P/qOZYAJsHhOH8lakzEi9KXJFAh5t4xAdS7L8twYEL\nVa/bsng09Hf836BDB6N+XvAiScu0UGbL5FQEVdpJtV/QbNhQZSF5zEPbEcU0\n6OEs2FouFwwW1J2ot8mLYDJ+GS9NA1NzicED35unMmsYl/HD3+Jzn1kztC0P\nxM/Q\r\n=Blft\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/weak-storage.umd.js","types":"index.d.ts","module":"index.js","gitHead":"3d6244486b5f2c7eeb1a9ccf4832b4bb6522b35b","scripts":{"test":"jest","build":"rollup -c rollup.config.js","test:watch":"jest --watch"},"_npmUser":{"name":"actualwave","email":"burdiuz@gmail.com"},"repository":{"url":"git+https://github.com/burdiuz/js-weak-storage.git","type":"git"},"_npmVersion":"6.10.2","description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","directories":{},"_nodeVersion":"12.9.1","_hasShrinkwrap":false,"devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","typescript":"^3.8.3","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@rollup/plugin-typescript":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/weak-storage_0.0.1_1588532578345_0.04416988006056699","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@actualwave/weak-storage","version":"0.0.2","author":"","license":"MIT","_id":"@actualwave/weak-storage@0.0.2","maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"homepage":"https://github.com/burdiuz/js-weak-storage#readme","bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"dist":{"shasum":"dbdc3bee7b777110fe8629311ae81c190fd03b46","tarball":"https://registry.npmjs.org/@actualwave/weak-storage/-/weak-storage-0.0.2.tgz","fileCount":7,"integrity":"sha512-ewKCPooNB3WLfY6GyACIk1qOyuK9KTvmMJk9FG03CgIlBjOoyv54ambBU38sUJQJ+dJGRpfcvbRwcfPXAqVycg==","signatures":[{"sig":"MEUCICE0QwIRjae9N6K9/+CjmU5yYcHD8IWqE0cXMZUxCx+pAiEAltcAokIp+HVewf02CYCgPV5dt15vporjYpN3GgjYOZQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12491,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJetjiVCRA9TVsSAnZWagAAo9cP/jJFtNp5SwMgDPuU8Aoo\nj5m6RHfu2FhgAXgu0qVv3DuxDYY8XNFo0ZiKLawJ+jgfRkBKLPY5vcAm5I2s\nRUXrRvl3xP4zvEHQcVu0zmLjBNcHSvESYM/NRTmOhaGxGmU0Z+z0VKpov5N7\naVzqkOaqQhVqY4qlhT5ULGwuvgXm7GottXYslWN4owJKlqMXTdQQuP2bf9R2\nNFyjP2xqyql0B2qy5ivn+vdWSRwLHLAtRN8QJepiTnfpQdYuCLVmnuv84YlY\nEwYV/12vAoPvNgcqkKtSRarbHFbYl2xxRTVOsTTRkBhjqtbgzmhOqEEVmq+e\nbON5DROFyMWsBS4l44SfMt9ZUVWOz3LRreDpc6HgZzTLphhRrq5wa19NvWqX\nyzK3xIY1T6vj6m+3r4nqbtoxTndANMkfFBMJAlzLgrjmX3XHmgj/SxzYSBIg\n4m+4JgGiHvv3vnEwdoyYQNT/frQVi4OukhNsJxnEg3p4cM3VpcdH7YRBdfEu\nlubZj5y+NUUOYdLEjnlLOWCTze3C07xPFfHdAAL4Te74mCboUD1h6o7URaM7\nLCci0XSmvm5YPG7L1rpszE8aLYyjIYFFBL/jRwEkUydph6gIrIsl8Dnq2zbE\nQVWooyGWQScsQUtEWK4uEKjOOFc9WxwVN5F4wWBeNoR1KHez6XfZSICqkuf/\nZYH3\r\n=l+ps\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/weak-storage.umd.js","types":"index.d.ts","module":"index.js","gitHead":"3d6244486b5f2c7eeb1a9ccf4832b4bb6522b35b","scripts":{"test":"jest","build":"rollup -c rollup.config.js","test:watch":"jest --watch"},"_npmUser":{"name":"actualwave","email":"burdiuz@gmail.com"},"repository":{"url":"git+https://github.com/burdiuz/js-weak-storage.git","type":"git"},"_npmVersion":"6.10.2","description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","directories":{},"_nodeVersion":"12.9.1","_hasShrinkwrap":false,"devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","typescript":"^3.8.3","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@rollup/plugin-typescript":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/weak-storage_0.0.2_1589000340895_0.9699353036292508","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@actualwave/weak-storage","version":"0.0.3","author":"","license":"MIT","_id":"@actualwave/weak-storage@0.0.3","maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"homepage":"https://github.com/burdiuz/js-weak-storage#readme","bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"dist":{"shasum":"1aec05b6f3e662ea0c0a71fb959e5903e44fb9c5","tarball":"https://registry.npmjs.org/@actualwave/weak-storage/-/weak-storage-0.0.3.tgz","fileCount":7,"integrity":"sha512-SF2ab1CKu5T+PhfNnrjvK6FwkSTXM+rx2M7TaVhiOrGSUGPK+i8uuRzwOlM/PXJAUwu0Ak3CsHjl0Z/pV7UGzA==","signatures":[{"sig":"MEUCIQDJ3WZ8v76uuKMM5QX/9V7ZQ9r3Fu9WoTJKxMt8m95Z7wIgEHQfzSfpizd1J9mqZwxGQeRd5rE6mQ+p2Ug1TFp7XH8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12573,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJet4qiCRA9TVsSAnZWagAAPvIQAJvlT5JnffAPPBFAYYCw\npRHiAO33lQDtB0dbrbV3evh6HcHARdM69dOiC16aJI8gO0xUX/a5I9FbT1BD\nBvc+KGZsJgPcXNFcKm2KWHCGTB8nnzYR8hY2BdAwuqRISlVHe8H03nn4gfi9\nXA8oQuWgnrxVevIWmJ/yeHpFXN2magaKJHYFhngjNPxEZEdQqVoGK++Kki2R\nwp3IAjdOHvL+1qdUjc9hgWZeYaRNxQMY1DhDQgSvOWAHMA0x5xQ5UVrcTScB\nO2I+NuJ8F8HXY2DuHX3ts4QnxahEuNdPkDf8PwN/uPQNjQu564/4r4uBvfEB\nigGFiGajwTCT+DnLaB1pZ+G0LkllHxkmIiE0oXwcacqvhgrS7n/BIWUezJWI\nD8PuaqDUPLSYQ4ovc7/8t+4cIHjtPcs3fOZesMf93+u11t+NVUpPrIafoSDV\n/H2ZqeyFRcfcCR3sTxsz3KzZVf1GbGGsyIh2wfw+HHwwpRO12+A0K7lc1UbO\nGG8xXdfww4lRmS1mZpf0/dzMGZH7M3MULtS0W1qF+HZ1CvkA4xXyWYzLIHtO\nmf0rf7mDR+jQyolgXSiytzbUP9gaW2yZ37adLf/btBCWyKLr/u8evNIFeNm7\n3u7UwxMGj9UB3JEPe/N7JrDK43wwp3WINRQoUKEF4tyrQRjpKbq2C+6+CgqB\nGHlA\r\n=DHgQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/weak-storage.umd.js","types":"index.d.ts","module":"index.js","gitHead":"3e19d3f7fd1b9d5125b1b2868ab099a49a5f2ce4","scripts":{"test":"jest","build":"rollup -c rollup.config.js","test:watch":"jest --watch"},"_npmUser":{"name":"actualwave","email":"burdiuz@gmail.com"},"repository":{"url":"git+https://github.com/burdiuz/js-weak-storage.git","type":"git"},"_npmVersion":"6.10.2","description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","directories":{},"_nodeVersion":"12.9.1","_hasShrinkwrap":false,"devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","typescript":"^3.8.3","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@rollup/plugin-typescript":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/weak-storage_0.0.3_1589086882170_0.5214757218905559","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"@actualwave/weak-storage","version":"0.1.0","author":"","license":"MIT","_id":"@actualwave/weak-storage@0.1.0","maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"homepage":"https://github.com/burdiuz/js-weak-storage#readme","bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"dist":{"shasum":"bfac58a1bcd0c300acf253ef4b05b0619ff951d0","tarball":"https://registry.npmjs.org/@actualwave/weak-storage/-/weak-storage-0.1.0.tgz","fileCount":8,"integrity":"sha512-tZltOrE6GGKPdWvd6KhdtGt0aQRUBSofrd7iaUs7MGplkDHlXzunpVIhCr4EGURjnKd7hRtaFvfNamJJNqBkiQ==","signatures":[{"sig":"MEYCIQDoC9G7PeMJQJ4mBIW+qbNvWCCaQpaFms90jfITrOWzQQIhALsKAYHAlmP5Tz8AvTVK53My5mybQOWZFyyyZ5Att1ho","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16914,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhxHmuCRA9TVsSAnZWagAAttoP/jEob1UFkcGX4sDia/Eh\n+V5gmpZB6xh1Aq+D7SzbNDAyUPz3vBZkMAGdRPVm+mtF3BqRfZ6ZoKDmSbcq\nkcPRhLldOW1dBBeTXID5Hxz6PsKUM5749gPJHkjPBOuwt1Rfi+vuMZ2br5xm\n42EZ3Xk0wi0zRhidWzhjxPGVjHsglFv3yxDrDF4hNuOc3ILM/ZQj+VK5y/tA\nnWnB+XS/UYImpsd2408x6Cvkr2hV+7KxGwhobuJh/RAW9lT6KJYlyIIa66XA\n1LXgbtMigSsqcgA3mKwd7/kYMZDNW27V7K0Kr9lRTTSPjRpnYZApl+EuIWpi\nOS+0Psz3YXqccFEtHai96K2NqfQ/oWhCiJPrEGilSLPXTt4q1dnNuA1HwbAA\n0Wl+jvahCVsK4WxUTvqDh/IjP83OnrdlyxnGknZArDek74m6iq3atJuk1vVv\nA5gT1BRifVYMWAaZZkFtvlaumD0Dja61HEHFkVubNE5TWVaPNCE50lCF0M3K\nYtME8LJP1s8180qYit0SjImT11FWEbZI66Exmq+zdJcP6T38HioAggKhsIMH\nBjT0a6AFQmVbE8NVejveBFrBV6Kvpfjcj6OePIfaACoIqN9g1XbHuC/xJwX3\n9hQWF/ONT+Xg2TqcoUwFTKwGQda7SGkbsAzEmXrjwPNE75vvSCqSlVI/F0tq\nB5Fv\r\n=aznE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","types":"index.d.ts","module":"index.es.js","gitHead":"15dcf5c1421a76f68987f4ed48477881b34e8bb6","scripts":{"test":"jest","build":"rollup -c rollup.config.js","test:watch":"jest --watch"},"_npmUser":{"name":"actualwave","email":"burdiuz@gmail.com"},"repository":{"url":"git+https://github.com/burdiuz/js-weak-storage.git","type":"git"},"_npmVersion":"7.18.1","description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","directories":{},"_nodeVersion":"16.4.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","typescript":"^3.8.3","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@rollup/plugin-typescript":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/weak-storage_0.1.0_1635452671287_0.15676565051708868","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@actualwave/weak-storage","version":"0.1.1","author":"","license":"MIT","_id":"@actualwave/weak-storage@0.1.1","maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"homepage":"https://github.com/burdiuz/js-weak-storage#readme","bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"dist":{"shasum":"59cf8e4b848631d3e91c9086dd2399df91a1e7cb","tarball":"https://registry.npmjs.org/@actualwave/weak-storage/-/weak-storage-0.1.1.tgz","fileCount":8,"integrity":"sha512-biIIUuO3gHM3he98uzH5LxdrLuaOadk5O1cm3PNWeIGn5ZhB0L11bV7N10YtuF5RxzVPoscJwK696lvvxr6uPw==","signatures":[{"sig":"MEUCIQDQteL8cKWLFCNV5YzeBDdTIMJkItVMf1krSxhvGc3dbgIgeC83pMVmnqKbTVXraNYjnB/8XnFlrfmvs5ylOyoM3SE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34893},"main":"index.js","type":"module","types":"index.d.ts","module":"index.es.js","gitHead":"c91835bc4af86aaa19c78f8335fa57f346d3bc10","scripts":{"test":"jest","build":"rollup -c rollup.config.js","test:watch":"jest --watch","test:coverage":"jest --coverage"},"_npmUser":{"name":"actualwave","email":"burdiuz@gmail.com"},"repository":{"url":"git+https://github.com/burdiuz/js-weak-storage.git","type":"git"},"_npmVersion":"11.5.1","description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","directories":{},"_nodeVersion":"24.6.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tslib":"^2.8.1","rollup":"^4.60.2","ts-jest":"^29.1.5","typescript":"^5.4.5","@types/jest":"^29.5.12","@types/node":"^20.14.0","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@rollup/plugin-typescript":"^12.3.0"},"_npmOperationalInternal":{"tmp":"tmp/weak-storage_0.1.1_1777133169436_0.630217657433473","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@actualwave/weak-storage","version":"0.2.0","description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","type":"module","main":"index.js","module":"index.es.js","types":"types/index.d.ts","scripts":{"build":"rollup -c rollup.config.js","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage"},"repository":{"type":"git","url":"git+https://github.com/burdiuz/js-weak-storage.git"},"author":"","license":"MIT","bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"homepage":"https://github.com/burdiuz/js-weak-storage#readme","devDependencies":{"@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@rollup/plugin-typescript":"^12.3.0","@types/jest":"^29.5.12","@types/node":"^20.14.0","jest":"^29.7.0","rollup":"^4.60.2","rollup-plugin-copy":"^3.5.0","ts-jest":"^29.1.5","tslib":"^2.8.1","typescript":"^5.4.5"},"_id":"@actualwave/weak-storage@0.2.0","gitHead":"92c2a1e0ffd37ce4df5bed29c69bb42ecd7f66ed","_nodeVersion":"24.6.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-2gwd0h+o7NcFZa21pJ99mSyGx1BRxUGFaJ28VdlYHX1MFB64uNqO6qnuowIzLaF1bKlFeQb5szuB0woEuJ29DA==","shasum":"76886d689fdefefeebe6a187084887feda2c71fd","tarball":"https://registry.npmjs.org/@actualwave/weak-storage/-/weak-storage-0.2.0.tgz","fileCount":18,"unpackedSize":72902,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDs7df+uNHs033ZukG9TfTso8ourhkBK/y44lLy1PILegIhAPTb2R0KTg3ZHP1CtpYZUOtiugmaopT4CqtYd978daQL"}]},"_npmUser":{"name":"actualwave","email":"burdiuz@gmail.com"},"directories":{},"maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/weak-storage_0.2.0_1778700031741_0.10467597006657003"},"_hasShrinkwrap":false}},"time":{"created":"2020-05-03T19:02:58.293Z","modified":"2026-05-13T19:20:32.037Z","0.0.1":"2020-05-03T19:02:58.446Z","0.0.2":"2020-05-09T04:59:01.004Z","0.0.3":"2020-05-10T05:01:22.296Z","0.1.0":"2021-10-28T20:24:31.426Z","0.1.1":"2026-04-25T16:06:09.581Z","0.2.0":"2026-05-13T19:20:31.914Z"},"bugs":{"url":"https://github.com/burdiuz/js-weak-storage/issues"},"license":"MIT","homepage":"https://github.com/burdiuz/js-weak-storage#readme","repository":{"type":"git","url":"git+https://github.com/burdiuz/js-weak-storage.git"},"description":"WeakStorage and WeakRefMap are based on WeakRef objects allowing to store values as weak references.","maintainers":[{"name":"actualwave","email":"burdiuz@gmail.com"}],"readme":"# @actualwave/weak-storage\n\nA `Map`-like collection that holds its **values as weak references**, letting the garbage collector reclaim them when nothing else holds a reference. Built on the [`WeakRef`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef) and [`FinalizationRegistry`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry) APIs.\n\nTwo classes are provided:\n\n| Class | Description |\n|---|---|\n| `WeakValueMap<K, V>` | Map with weak values. Any key type; iteration skips collected entries. |\n| `WeakStorage<K, V>` | Extends `WeakValueMap` with a reverse index — look up the key given a value. |\n\n## Requirements\n\n| Environment | Minimum version |\n|---|---|\n| Node.js | 14.6+ |\n| Chrome / Edge | 84+ |\n| Firefox | 79+ |\n| Safari | 14.1+ |\n\nBoth `WeakRef` and `FinalizationRegistry` must be available. Check [MDN compatibility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef#browser_compatibility) for the latest data.\n\n## Installation\n\n```sh\nnpm install @actualwave/weak-storage\n```\n\n## Quick Start\n\n```js\nimport { WeakStorage } from '@actualwave/weak-storage';\n\nconst store = new WeakStorage();\n\nconst user = { id: 1, name: 'Alice' };\nstore.set('user:1', user);\n\nstore.get('user:1');    // { id: 1, name: 'Alice' }\nstore.getKey(user);     // 'user:1'\nstore.has('user:1');    // true\n\n// After the variable goes out of scope and GC runs,\n// get() returns undefined and iteration skips the entry.\n```\n\n---\n\n## `WeakValueMap<K, V>`\n\nA drop-in replacement for `Map` where **values** are weakly referenced. Keys can be anything — strings, numbers, symbols, or objects.\n\n### Constructor\n\n```ts\nnew WeakValueMap(FinalizationRegistryClass?: IFinalizationRegistryConstructor | null)\n```\n\n| Option | Default | Description |\n|---|---|---|\n| `FinalizationRegistryClass` | `globalThis.FinalizationRegistry` | Constructor used to create the internal `FinalizationRegistry` that removes stale entries when a value is collected. Pass `null` to disable auto-cleanup and manage it manually via `verify()`. If the global `FinalizationRegistry` is not available (e.g. Hermes / React Native), a console warning is emitted and auto-cleanup is skipped. |\n\n```js\nimport { WeakValueMap } from '@actualwave/weak-storage';\n\n// With auto-cleanup (default) — uses globalThis.FinalizationRegistry\nconst map = new WeakValueMap();\n\n// Without auto-cleanup — use verify() to prune manually\nconst manual = new WeakValueMap(null);\n\n// Custom FinalizationRegistry implementation\nconst custom = new WeakValueMap(MyFinalizationRegistry);\n```\n\n### `set(key, value): this`\n\nStores a value under `key` as a weak reference. Returns `this` for chaining.\n\n```js\nmap.set('a', { x: 1 })\n   .set('b', { x: 2 })\n   .set('c', { x: 3 });\n```\n\n### `get(key): V | undefined`\n\nReturns the value, or `undefined` if the key is missing or the value was collected.\n\n```js\nconst value = map.get('a'); // { x: 1 } or undefined\n```\n\n### `has(key): boolean`\n\nReturns `true` only if the key exists **and** its value is still alive.\n\n```js\nmap.has('a'); // true\nmap.has('missing'); // false\n```\n\n### `delete(key): boolean`\n\nRemoves the entry. Returns `true` if the key existed.\n\n```js\nmap.delete('a'); // true\nmap.delete('a'); // false — already gone\n```\n\n### `clear(): void`\n\nRemoves all entries.\n\n```js\nmap.clear();\nmap.approximateSize; // 0\n```\n\n### `forEach(callback): void`\n\nIterates over **live entries only** — collected values are silently skipped.\n\n```js\nmap.forEach((value, key, map) => {\n  console.log(key, value);\n});\n```\n\n### `keys()`, `values()`, `entries()`\n\nReturn `IterableIterator` instances that skip any entries whose values have been collected.\n\n```js\nfor (const key of map.keys()) { /* ... */ }\nfor (const value of map.values()) { /* ... */ }\nfor (const [key, value] of map.entries()) { /* ... */ }\n\n// Spread also works\nconst liveKeys = [...map.keys()];\n```\n\n### `approximateSize: number`\n\nReturns the number of internal map entries. This **may include stale entries** that have been collected but whose `FinalizationRegistry` callback has not yet fired.\n\n```js\nmap.set('x', { n: 1 });\n// After GC but before the finalizer runs:\nmap.approximateSize; // still 1\nmap.has('x');        // false — correctly reports the value is gone\n```\n\nIf you need an accurate count, call `verify()` first:\n\n```js\nmap.verify();\nmap.approximateSize; // reflects only live entries\n```\n\n### `verify(): void`\n\nRebuilds the internal map, discarding any entries whose values have been collected. Useful when:\n- Auto-cleanup is disabled (`null` passed to the constructor) and you want to reclaim memory explicitly.\n- You need `approximateSize` to reflect the true live count.\n\n```js\nconst map = new WeakValueMap(null); // no auto-cleanup\n\n// ... time passes, some values get collected ...\n\nmap.verify();                 // prune dead entries\nconsole.log(map.approximateSize); // accurate live count\n```\n\n---\n\n## `WeakStorage<K, V>`\n\nExtends `WeakValueMap` with a **reverse index** backed by a `WeakMap`, giving O(1) key lookup from a value. Values must be objects (required by `WeakMap`).\n\nInherits all `WeakValueMap` methods. Additionally:\n\n### `getKey(value): K | undefined`\n\nReturns the key associated with a value, or `undefined` if the value was never stored or the entry was deleted.\n\n```js\nimport { WeakStorage } from '@actualwave/weak-storage';\n\nconst store = new WeakStorage();\n\nconst request = { url: '/api/users' };\nstore.set('req-1', request);\n\nstore.getKey(request); // 'req-1'\n```\n\n`delete()` and `clear()` both clean up the reverse index:\n\n```js\nstore.delete('req-1');\nstore.getKey(request); // undefined\n\nstore.clear();\nstore.getKey(request); // undefined\n```\n\n---\n\n## TypeScript\n\nBoth classes are fully generic. The value type `V` is constrained to `object` because `WeakRef` cannot hold primitives.\n\n```ts\nimport { WeakValueMap, WeakStorage } from '@actualwave/weak-storage';\n\ninterface Session {\n  userId: string;\n  token: string;\n}\n\n// Explicit generics\nconst sessions = new WeakValueMap<string, Session>();\nsessions.set('sess-abc', { userId: '1', token: 'xyz' });\n\nconst session = sessions.get('sess-abc'); // Session | undefined\n\n// WeakStorage with bidirectional lookup\nconst store = new WeakStorage<string, Session>();\nstore.set('sess-abc', { userId: '1', token: 'xyz' });\n\nstore.getKey({ userId: '1', token: 'xyz' }); // string | undefined\n```\n\nThe exported interfaces let you substitute custom `WeakRef` / `FinalizationRegistry` implementations — useful for testing or non-standard environments:\n\n```ts\nimport type {\n  IWeakRef,\n  IWeakRefConstructor,\n  IFinalizationRegistry,\n  IFinalizationRegistryConstructor,\n} from '@actualwave/weak-storage';\n```\n\n---\n\n## How weak references work\n\nA `WeakRef` wraps an object without keeping it alive. When the JavaScript engine determines that no strong references remain, it may collect the object. Calling `ref.deref()` afterwards returns `undefined`.\n\n```\nset('k', obj)\n  └─ map.set('k', new WeakRef(obj))\n  └─ finalizer.register(obj, 'k')\n\nget('k')\n  └─ map.get('k').deref()   → obj if alive, undefined if collected\n\n[GC runs, obj is collected]\n  └─ FinalizationRegistry fires → map.delete('k')  (when FinalizationRegistryClass is set)\n```\n\n### Key reuse guard\n\nIf a key is reused before the finalizer fires for the old value, the cleanup callback checks that the current ref is also dead before deleting. A live replacement value is never evicted:\n\n```js\nmap.set('k', oldValue);\n// oldValue gets collected, but before the finalizer fires:\nmap.set('k', freshValue);\n// finalizer fires for 'k' — but freshValue is alive, so the entry is kept\nmap.get('k'); // freshValue ✓\n```\n\n---\n\n## Caveats\n\n- **GC timing is non-deterministic.** A collected value may not disappear from `get()` immediately after all strong references are dropped — the engine decides when to collect. Never rely on finalizers for correctness-critical logic.\n- **`approximateSize` can lag.** It reflects the raw internal map size, which can include stale entries between GC and finalizer execution. Use `verify()` + `approximateSize` when an exact count matters.\n- **`WeakStorage.getKey()` does not survive GC.** The reverse index is a `WeakMap`, so when the value is collected, its reverse entry is also automatically removed.\n- **Primitives as values are not supported.** `WeakRef` can only wrap objects. Passing a primitive to `set()` will throw at runtime.\n","readmeFilename":"README.md"}