{"_id":"@alshdavid/worker-shared-memory","_rev":"6-91f0e304e03bd594231446ac08c67cc5","name":"@alshdavid/worker-shared-memory","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.2":{"name":"@alshdavid/worker-shared-memory","version":"0.0.2","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.2","@alshdavid/worker-shared-memory_linux-arm64":"0.0.2","@alshdavid/worker-shared-memory_macos-amd64":"0.0.2","@alshdavid/worker-shared-memory_macos-arm64":"0.0.2","@alshdavid/worker-shared-memory_windows-amd64":"0.0.2","@alshdavid/worker-shared-memory_windows-arm64":"0.0.2"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.2","@alshdavid/worker-shared-memory_linux-arm64":"0.0.2","@alshdavid/worker-shared-memory_macos-amd64":"0.0.2","@alshdavid/worker-shared-memory_macos-arm64":"0.0.2","@alshdavid/worker-shared-memory_windows-amd64":"0.0.2","@alshdavid/worker-shared-memory_windows-arm64":"0.0.2"},"_id":"@alshdavid/worker-shared-memory@0.0.2","_integrity":"sha512-A2m0oKfJlKqM44+XxJ2tG7reRXVrR33uPTaShNuJWPzUS0lBHzfx2vU9PqDzrezEhBQTTQd0YZQzqdmxu4TyAA==","_resolved":"/tmp/eabf033e5ff136f31c9e5b6ffa3e0621/alshdavid-worker-shared-memory-0.0.2.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.2.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-A2m0oKfJlKqM44+XxJ2tG7reRXVrR33uPTaShNuJWPzUS0lBHzfx2vU9PqDzrezEhBQTTQd0YZQzqdmxu4TyAA==","shasum":"16a0930c215e8a777dc29b6e5cda6a0e011b666d","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.2.tgz","fileCount":5,"unpackedSize":7554,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCxhfRbB1HgyfKslmIlG2NJgugZ+1a+eDsOFiwUSoMUKQIgLGfD35saZDakcn9dQkzq9uMkdEDa3XWhi1KlXsj54Xk="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.2_1699862571121_0.0000030226437952585172"},"_hasShrinkwrap":false},"0.0.3":{"name":"@alshdavid/worker-shared-memory","version":"0.0.3","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.3","@alshdavid/worker-shared-memory_linux-arm64":"0.0.3","@alshdavid/worker-shared-memory_macos-amd64":"0.0.3","@alshdavid/worker-shared-memory_macos-arm64":"0.0.3","@alshdavid/worker-shared-memory_windows-amd64":"0.0.3","@alshdavid/worker-shared-memory_windows-arm64":"0.0.3"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.3","@alshdavid/worker-shared-memory_linux-arm64":"0.0.3","@alshdavid/worker-shared-memory_macos-amd64":"0.0.3","@alshdavid/worker-shared-memory_macos-arm64":"0.0.3","@alshdavid/worker-shared-memory_windows-amd64":"0.0.3","@alshdavid/worker-shared-memory_windows-arm64":"0.0.3"},"_id":"@alshdavid/worker-shared-memory@0.0.3","_integrity":"sha512-zmo5Xzlg5bzfJPONtNpXZPVTt8rFEx4Lt2eZlHFUo/LSSb5z86SZNmAm/9FJVl2Cx+x3uQ6CUFM6b1hFV598ag==","_resolved":"/tmp/c75a21abd83f35ca18640d13891d36b1/alshdavid-worker-shared-memory-0.0.3.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.3.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-zmo5Xzlg5bzfJPONtNpXZPVTt8rFEx4Lt2eZlHFUo/LSSb5z86SZNmAm/9FJVl2Cx+x3uQ6CUFM6b1hFV598ag==","shasum":"6ce0f82abc90b2516995d1761082ff448a688494","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.3.tgz","fileCount":5,"unpackedSize":7554,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDtPchAJZZFHOyCs1RQC5nCwV202nJpgY/rBsYOKFrZoQIhANJMzicUK5mzVe8jyTLB1B5gzv5B8NkgLGVjO+u7TVfl"}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.3_1699862882591_0.010615834024712667"},"_hasShrinkwrap":false},"0.0.4":{"name":"@alshdavid/worker-shared-memory","version":"0.0.4","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.4","@alshdavid/worker-shared-memory_linux-arm64":"0.0.4","@alshdavid/worker-shared-memory_macos-amd64":"0.0.4","@alshdavid/worker-shared-memory_macos-arm64":"0.0.4","@alshdavid/worker-shared-memory_windows-amd64":"0.0.4","@alshdavid/worker-shared-memory_windows-arm64":"0.0.4"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.4","@alshdavid/worker-shared-memory_linux-arm64":"0.0.4","@alshdavid/worker-shared-memory_macos-amd64":"0.0.4","@alshdavid/worker-shared-memory_macos-arm64":"0.0.4","@alshdavid/worker-shared-memory_windows-amd64":"0.0.4","@alshdavid/worker-shared-memory_windows-arm64":"0.0.4"},"_id":"@alshdavid/worker-shared-memory@0.0.4","_integrity":"sha512-WfcetGQ6A6fJwYcgtBj8+091QbP9e9ZjFelVZB8tW6JESvRkSo7d9MMtH5N4kdaF5rk4vrrKq7I8Rh+reX6wdg==","_resolved":"/tmp/fbed40e8e73c38c6a98af65fbe5272fd/alshdavid-worker-shared-memory-0.0.4.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.4.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-WfcetGQ6A6fJwYcgtBj8+091QbP9e9ZjFelVZB8tW6JESvRkSo7d9MMtH5N4kdaF5rk4vrrKq7I8Rh+reX6wdg==","shasum":"9850d672844dd606add137a4d06032b8797a6caf","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.4.tgz","fileCount":5,"unpackedSize":7554,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID433SdwoyqXXg+oGb0SesRy2z4XP/jFnxuVez0mwHPwAiEAi3cFQOpVLze4xGGSwSH9EcGo4YNP+7aJzimDCrxa1sQ="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.4_1699863187482_0.5982024315075658"},"_hasShrinkwrap":false},"0.0.5":{"name":"@alshdavid/worker-shared-memory","version":"0.0.5","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.5","@alshdavid/worker-shared-memory_linux-arm64":"0.0.5","@alshdavid/worker-shared-memory_macos-amd64":"0.0.5","@alshdavid/worker-shared-memory_macos-arm64":"0.0.5","@alshdavid/worker-shared-memory_windows-amd64":"0.0.5","@alshdavid/worker-shared-memory_windows-arm64":"0.0.5"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.5","@alshdavid/worker-shared-memory_linux-arm64":"0.0.5","@alshdavid/worker-shared-memory_macos-amd64":"0.0.5","@alshdavid/worker-shared-memory_macos-arm64":"0.0.5","@alshdavid/worker-shared-memory_windows-amd64":"0.0.5","@alshdavid/worker-shared-memory_windows-arm64":"0.0.5"},"_id":"@alshdavid/worker-shared-memory@0.0.5","_integrity":"sha512-kikIOJVzQZVeMb3C2J0Iua/ybW3AiEls6LOS8E9nniv/sn0dO5MwrLLg0Dvjsx9ahCju0H52Vr7ceAB3Dnv+RA==","_resolved":"/tmp/3996566107c39569dd26ac6bda73e8bb/alshdavid-worker-shared-memory-0.0.5.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.5.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-kikIOJVzQZVeMb3C2J0Iua/ybW3AiEls6LOS8E9nniv/sn0dO5MwrLLg0Dvjsx9ahCju0H52Vr7ceAB3Dnv+RA==","shasum":"880185c7b7d902946bab072020f1611989bac4dd","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.5.tgz","fileCount":6,"unpackedSize":10787,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7v2QGpXOug9oybn11CNZUxQvhCmDFDk0p3DXrbJFJhwIgaw/3p/YeEOdrK+lDuXBcJkb+F7+SDomqzcrTR5VPK0E="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.5_1699865021751_0.6917406040531151"},"_hasShrinkwrap":false},"0.0.6":{"name":"@alshdavid/worker-shared-memory","version":"0.0.6","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.6","@alshdavid/worker-shared-memory_linux-arm64":"0.0.6","@alshdavid/worker-shared-memory_macos-amd64":"0.0.6","@alshdavid/worker-shared-memory_macos-arm64":"0.0.6","@alshdavid/worker-shared-memory_windows-amd64":"0.0.6","@alshdavid/worker-shared-memory_windows-arm64":"0.0.6"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.6","@alshdavid/worker-shared-memory_linux-arm64":"0.0.6","@alshdavid/worker-shared-memory_macos-amd64":"0.0.6","@alshdavid/worker-shared-memory_macos-arm64":"0.0.6","@alshdavid/worker-shared-memory_windows-amd64":"0.0.6","@alshdavid/worker-shared-memory_windows-arm64":"0.0.6"},"_id":"@alshdavid/worker-shared-memory@0.0.6","_integrity":"sha512-SPP3JULX83h3UHF1RBOFlqBHo7JJ7vRJhc/HX+da/zBUnWpqYTfwwk4QD7cHe7nd1PvsQIEFMW5Z57gDM9+x8g==","_resolved":"/tmp/3a0b147e330dcb3265965d506ea693e1/alshdavid-worker-shared-memory-0.0.6.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.6.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-SPP3JULX83h3UHF1RBOFlqBHo7JJ7vRJhc/HX+da/zBUnWpqYTfwwk4QD7cHe7nd1PvsQIEFMW5Z57gDM9+x8g==","shasum":"8167e7720e36569f02d7a38f032f601092b53cf2","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.6.tgz","fileCount":6,"unpackedSize":10787,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHdgL1eISvj5pePTUOpH9OwE9L+GktuIlNSkoXiL0k5QAiEA6DLgi8YAGEiZEnSTLyOxf3GrM6N57SweZMskPD3wef0="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.6_1699865444304_0.45251977907587015"},"_hasShrinkwrap":false},"0.0.7":{"name":"@alshdavid/worker-shared-memory","version":"0.0.7","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.7","@alshdavid/worker-shared-memory_linux-arm64":"0.0.7","@alshdavid/worker-shared-memory_macos-amd64":"0.0.7","@alshdavid/worker-shared-memory_macos-arm64":"0.0.7","@alshdavid/worker-shared-memory_windows-amd64":"0.0.7","@alshdavid/worker-shared-memory_windows-arm64":"0.0.7"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.7","@alshdavid/worker-shared-memory_linux-arm64":"0.0.7","@alshdavid/worker-shared-memory_macos-amd64":"0.0.7","@alshdavid/worker-shared-memory_macos-arm64":"0.0.7","@alshdavid/worker-shared-memory_windows-amd64":"0.0.7","@alshdavid/worker-shared-memory_windows-arm64":"0.0.7"},"_id":"@alshdavid/worker-shared-memory@0.0.7","_integrity":"sha512-FV3rGcVkFB6061yVqTRjJ1Cc4wOaV3e6uIXmMAPUASN43idQnbIh1gMSTTmJRdUqKDnHkcQlT+hHOcjrPrY60g==","_resolved":"/tmp/c8d325f37aa85299abaa0d30b2276670/alshdavid-worker-shared-memory-0.0.7.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.7.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-FV3rGcVkFB6061yVqTRjJ1Cc4wOaV3e6uIXmMAPUASN43idQnbIh1gMSTTmJRdUqKDnHkcQlT+hHOcjrPrY60g==","shasum":"1466ff490b4435d1be97f61a65eb8530fda38bb6","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.7.tgz","fileCount":6,"unpackedSize":11229,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB+4ySjeuoruK2RmA6ZFOnTGbZ5fHWa1QWsKcwKeDMYJAiEA/5UbzheRjjGue6LJpTiPd7etr0rQLPivNrzgK5hR2ow="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.7_1699865899936_0.46165290938254633"},"_hasShrinkwrap":false},"0.0.8":{"name":"@alshdavid/worker-shared-memory","version":"0.0.8","description":"A native module that allows workers to share memory","type":"commonjs","main":"index.js","types":"index.d.ts","author":{"name":"David Alsh"},"license":"MIT","optionalDependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.8","@alshdavid/worker-shared-memory_linux-arm64":"0.0.8","@alshdavid/worker-shared-memory_macos-amd64":"0.0.8","@alshdavid/worker-shared-memory_macos-arm64":"0.0.8","@alshdavid/worker-shared-memory_windows-amd64":"0.0.8","@alshdavid/worker-shared-memory_windows-arm64":"0.0.8"},"dependencies":{"@alshdavid/worker-shared-memory_linux-amd64":"0.0.8","@alshdavid/worker-shared-memory_linux-arm64":"0.0.8","@alshdavid/worker-shared-memory_macos-amd64":"0.0.8","@alshdavid/worker-shared-memory_macos-arm64":"0.0.8","@alshdavid/worker-shared-memory_windows-amd64":"0.0.8","@alshdavid/worker-shared-memory_windows-arm64":"0.0.8"},"_id":"@alshdavid/worker-shared-memory@0.0.8","_integrity":"sha512-kAZx8eaCwbZAe3tEVqX9cWr2oVYLu56ZaY4VBwR/6/U2C3HtwsEvpIeWsTw/QX+hwbo5pt9jkkzqdJENSlRw8A==","_resolved":"/tmp/79d1c8a9a9e51b5f45f98c44fc8a9228/alshdavid-worker-shared-memory-0.0.8.tgz","_from":"file:alshdavid-worker-shared-memory-0.0.8.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-kAZx8eaCwbZAe3tEVqX9cWr2oVYLu56ZaY4VBwR/6/U2C3HtwsEvpIeWsTw/QX+hwbo5pt9jkkzqdJENSlRw8A==","shasum":"3ebb7c79f688871b1e9145d4dce186957282e9d6","tarball":"https://registry.npmjs.org/@alshdavid/worker-shared-memory/-/worker-shared-memory-0.0.8.tgz","fileCount":6,"unpackedSize":11232,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcCO+cIxbc+jV90ub2uKQI8N8jLZzBj1ayDtxu4HibagIgJcI0/W2XSuIYh6kHOMW3S6WZ7y5Oi92Te1x4+VAyu1M="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/worker-shared-memory_0.0.8_1699873496663_0.25781949203205623"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-13T08:02:50.991Z","0.0.2":"2023-11-13T08:02:51.405Z","modified":"2023-11-13T11:04:57.052Z","0.0.3":"2023-11-13T08:08:02.796Z","0.0.4":"2023-11-13T08:13:07.643Z","0.0.5":"2023-11-13T08:43:41.946Z","0.0.6":"2023-11-13T08:50:44.522Z","0.0.7":"2023-11-13T08:58:20.084Z","0.0.8":"2023-11-13T11:04:56.843Z"},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"description":"A native module that allows workers to share memory","author":{"name":"David Alsh"},"license":"MIT","readme":"# Node.js Shared Memory Across Workers\n\nThis npm package exposes a centralized storage for state shared between workers.\n\n## Installation\n\n```bash\nnpm install @alshdavid/worker-shared-memory\n```\n\n## Usage\n\n```javascript\n// main.js\nimport { StringRef, MapRef } from '@alshdavid/worker-shared-memory'\nimport { Worker } from 'node:worker_threads'\n\n// Spawn worker\nconst worker = new Worker('./worker.js')\n\n// Create Map in store\nconst map = new MapRef()\nmap.set('foo', StringRef.from(\"Hello World\"))\n\n// Give the worker the id of the Map\n// I might add \"named\" values in future so you don't need to transfer IDs\nworker.postMessage(map.id)\n```\n\n```javascript\n// worker.js\nimport { MapRef } from '@alshdavid/worker-shared-memory'\nimport { parentPort } from 'node:worker_threads'\n\n// Get the ID of the Map\nparentPort.addEventListener('message', ({ data: map_id }) => {\n    // Connect to the same map\n    const map = new MapRef(map_id)\n\n    console.log(map.get('foo').obtainValue()) // \"Hello World\"\n})\n```\n\n# Types\n\n```javascript\nimport { StringRef, NumberRef, MapRef, VectorRef } from '@alshdavid/worker-shared-memory'\n\nconst str = new StringRef() // Empty string (utf8 string)\nconst num = new NumberRef() // Empty number (64 bit float)\nconst map = new MapRef()    // Key/Value store that holds refs\nconst vec = new VectorRef() // Dynamic array that holds refs\n```\n\n## Structs\n\nYou can define and instantiate structs\n\n```javascript\n// Define struct\nconst Foo = new StructFactory({\n    key_1: \"string\",\n    key_2: \"number\",\n})\n\nconst foo = Foo.new({\n    key_1: \"foo\",\n    key_2: 42,\n})\n\nconsole.log(foo.getKey('key_1')) // 'foo'\nfoo.setKey('key_1', 'something else')\n```\n\nYou can access structs through a JavaScript proxy object for more ergonomic interactions. be mindful of accessing values as they are not references, the underlying value may change after it is obtained.\n\n```javascript\nconst Foo = new StructDefinition({\n    key_1: \"string\",\n    key_2: \"number\",\n})\n\nconst foo = Foo.new_proxy({\n    key_1: \"foo\",\n    key_2: 42,\n})\n\nconsole.log(foo.key_1) // 'foo'\nfoo.key_1 = 'bar' \nconsole.log(foo.key_1) // 'bar'\n```\n\n## Safety and Memory usage\n\nAll values are stored in a shared heap managed by the native module. Interacting with values occurs behind synchronization controls like mutexes and atomics.\n\nThe shared heap is not subject to the maximum heap size assigned to Node.js that you can modify via `—-max-old-space-size` - however to ensure minimal memory usage within the Node.js process + threads, values are passed by reference identifiers.\n\n```javascript\nimport { StringRef } from '@alshdavid/worker-shared-memory'\n\nconst str = StringRef.from('foo')\n\nconsole.log(str)               // { id: 342 }\nconsole.log(str.obtainValue()) // 'foo'\n```\n\nOnly after a value is obtained is it copied into the Node.js heap and will, at that point, contribute to memory usage within the process/thread memory pool.\n\nThe limitation is how many references you can hold in the process - which appears to be several billion under Node's default memory limit.\n\n## Manual Memory Management\n\nUnfortunately, usage of this library requires the manual cleanup of values stored in the shared value store and does expose the consumer to use after free errors. \n\nCaution is advised, particularly with Vectors and Maps as dropping them does not drop their held resources. Structs drop their assigned values.\n\n```javascript\nimport { StringRef } from '@alshdavid/worker-shared-memory'\n\nconst str = StringRef.from('foo')\n\nconsole.log(str.obtainValue()) // 'foo'\n\nstr.drop() // will deallocate the value\n\nconsole.log(str.obtainValue()) // Thrown Error ('use after free')\n```\n","readmeFilename":"README.md"}