{"_id":"@azerothian/nspaced","_rev":"3-9f6cec9a40d59f5fb91280b5120471b6","name":"@azerothian/nspaced","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@azerothian/nspaced","version":"0.0.1","keywords":[],"author":{"name":"Azerothian"},"license":"MIT","_id":"@azerothian/nspaced@0.0.1","maintainers":[{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"}],"dist":{"shasum":"b44cd78d4f7bdf384528556043c0eeacc47d81fb","tarball":"https://registry.npmjs.org/@azerothian/nspaced/-/nspaced-0.0.1.tgz","fileCount":7,"integrity":"sha512-IpI4PwXTFALos105e3Uue+qaASGDM+V3fG3YQujOSIPXEcxxHh/DgB6QDiLOMpVwo7rj2W9RDi++NyDErK3b2g==","signatures":[{"sig":"MEYCIQDdgIxc/ei5wfIJ44dVczWzaoaa/JvFnUtenrIuTpaBRgIhAITbIkk1+crbkYRfSuY9cwSXfvrn4RfAEVfCZIYEDAHz","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21148},"main":"lib/index.js","pnpm":{"onlyBuiltDependencies":["@swc/core","esbuild"]},"types":"lib/index.d.ts","gitHead":"f7ef29c89661d7b8b7556af4e55b1a402c9cef99","scripts":{"build":"rm -Rf ./lib ./types ./cjs || true; run-p build:*","build:main":"swc src --out-dir lib --strip-leading-paths -s","build:types":"tsc -p tsconfig.types.json","build:copy-dts":"copyfiles -u 1 \"src/**/*.d.ts\" lib","prepublishOnly":"pnpm run build"},"_npmUser":{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"},"_npmVersion":"10.8.2","description":"Drop in replacement for [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) * seems to be dead and has not been updated in a very long time,","directories":{},"_nodeVersion":"22.6.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","jest":"^29.7.0","ts-jest":"^29.3.1","ts-node":"^10.9.2","@swc/cli":"^0.6.0","@swc/core":"^1.11.16","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.14","npm-run-all2":"^7.0.2","@jest/globals":"^29.7.0","@swc/plugin-transform-imports":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nspaced_0.0.1_1744097991690_0.7724864787339605","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@azerothian/nspaced","version":"0.0.2","keywords":[],"author":{"name":"Azerothian"},"license":"MIT","_id":"@azerothian/nspaced@0.0.2","maintainers":[{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"}],"dist":{"shasum":"da0196942de5cf75a7de7b9435232204be429c91","tarball":"https://registry.npmjs.org/@azerothian/nspaced/-/nspaced-0.0.2.tgz","fileCount":23,"integrity":"sha512-2L+NLQkgFmeqQfVeWx5kYFwrMC8BgyCOxROtxSZkuiy0BM6gWcy+pBJROm6ieLTV5dsuw8k9fUDXpYNItIcdYQ==","signatures":[{"sig":"MEUCIQC2LWApVcV36qePAS8lQlZA2IodK/+NBw4iHmPuWsGC9gIgVyZY1FDwYWAxl8pMi1nUDCgzS8ix94hzE37IjnKJk5w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36144},"main":"cjs/index.js","pnpm":{"onlyBuiltDependencies":["@swc/core","esbuild"]},"type":"module","types":"lib/index.d.ts","module":"lib/index.js","gitHead":"e0c92dc22567b742d9e0225c823a1e93ae300c2e","scripts":{"build":"rm -Rf ./publish || true; mkdir ./publish && run-p build:*","build:cjs":"swc src --out-dir publish/cjs --config-file=.swcrc-cjs --strip-leading-paths -s","build:src":"copyfiles -u 1 \"src/**/*\" publish/src","build:main":"swc src --out-dir publish/lib --strip-leading-paths -s","build:types":"tsc -p tsconfig.types.json --outDir publish/types","build:readme":"cp ./README.md ./publish/README.md","package:yalc":"pnpm run build && cd publish && yalc publish","build:package":"tsx ./scripts/prepare-package.ts","build:copy-dts":"copyfiles -u 1 \"src/**/*.d.ts\" publish/lib"},"_npmUser":{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"},"_npmVersion":"10.9.0","description":"Drop in replacement for [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) * seems to be dead and has not been updated in a very long time,","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","jest":"^29.7.0","globby":"^14.1.0","ts-jest":"^29.3.1","ts-node":"^10.9.2","@swc/cli":"^0.6.0","@swc/core":"^1.11.16","@swc/jest":"^0.2.37","copyfiles":"^2.4.1","typescript":"^5.8.2","@types/node":"^22.13.14","npm-run-all2":"^7.0.2","@jest/globals":"^29.7.0","@swc/plugin-transform-imports":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nspaced_0.0.2_1747396301452_0.1030992402706763","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@azerothian/nspaced","version":"0.0.3","description":"Drop in replacement for [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) * seems to be dead and has not been updated in a very long time,","main":"cjs/index.js","types":"lib/index.d.ts","module":"lib/index.js","type":"module","keywords":[],"author":{"name":"Azerothian"},"license":"MIT","pnpm":{"onlyBuiltDependencies":["@swc/core","esbuild"]},"exports":{".":{"import":"./lib/index.mjs","require":"./cjs/index.js","types":"./types/index.d.ts"},"./index":{"import":"./lib/index.mjs","require":"./cjs/index.js","types":"./types/index.d.ts"}},"_id":"@azerothian/nspaced@0.0.3","gitHead":"fd1cc67cb5cfded46428fbaa63ff9a17c8e0f25a","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-7c6Y3PSvve9qFpLUS7Ncr/Q5w+Rbd9iKEGWGf/m1hbEIPqXHwhim1yb747JDCkYN5gYKbFOwoNR2yDNpLpUCDg==","shasum":"cc5795fdb9e918c3b626a1f6923358fb2323cf78","tarball":"https://registry.npmjs.org/@azerothian/nspaced/-/nspaced-0.0.3.tgz","fileCount":8,"unpackedSize":19378,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFuPupzFGzwEFgd+b3KrrS5A64MvQA9Caeulx+YYpvz5AiEAsDdY3sjTIVqstjZx9F9FPH20FDPzGw57ADKvNzbcP9k="}]},"_npmUser":{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"},"directories":{},"maintainers":[{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nspaced_0.0.3_1747397148482_0.7807443545198012"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-08T07:39:51.607Z","modified":"2025-05-16T12:05:48.923Z","0.0.1":"2025-04-08T07:39:52.076Z","0.0.2":"2025-05-16T11:51:41.692Z","0.0.3":"2025-05-16T12:05:48.686Z"},"author":{"name":"Azerothian"},"license":"MIT","keywords":[],"description":"Drop in replacement for [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) * seems to be dead and has not been updated in a very long time,","maintainers":[{"name":"matthew.m.mckenzie","email":"matthew.m.mckenzie@gmail.com"}],"readme":"# @azerothian/nspaced\n\nDrop in replacement for [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) * seems to be dead and has not been updated in a very long time, \n\n## TODO\n\nLook at bind/context setting, atm bind only binds it to the current context,\n\n\n\nThis is using [AsyncLocalStorage](https://github.com/nodejs/node/blob/main/doc/api/async_context.md#class-asynclocalstorage) instead of [async_hooks](https://github.com/nodejs/node/blob/main/doc/api/async_hooks.md)\n\nIt uses a Map to store the values and will clone the parent map when run is called.\n\n\n```typescript\nimport { createNamespace, getNamespace } from \"../src\";\n\nconst writer = createNamespace('writer');\nwriter.run(function () {\n  writer.set('value', 0);\n  requestHandler();\n});\n\nlet bindTest: any;\n\nfunction requestHandler() {\n  writer.run(function(outer) {\n    // writer.get('value') returns 0\n    // outer.value is 0\n    console.log(\"outer.value\", outer.get(\"value\")); // prints 0\n    writer.set('value', 1);\n    // writer.get('value') returns 1\n    console.log(\"outer.value\", outer.get(\"value\")); // prints 1\n    // outer.value is 1\n    process.nextTick(function() {\n      // writer.get('value') returns 1\n      // outer.value is 1\n      writer.run(function(inner) {\n        // writer.get('value') returns 1\n        // outer.value is 1\n        console.log(\"outer.value\", outer.get(\"value\")); // prints 1\n        // inner.value is 1\n        console.log(\"outer.value\", inner.get(\"value\")); // prints 1\n        writer.set('value', 2);\n        // writer.get('value') returns 2\n        // outer.value is 1\n        console.log(\"outer.value\", outer.get(\"value\")); // prints 1\n        // inner.value is 2\n        console.log(\"outer.value\", inner.get(\"value\")); // prints 2\n        bindTest = writer.bind(function() {\n          const ns = getNamespace('writer');\n          console.log(\"outer.value\", ns.get(\"value\")); // prints 2\n        });\n      });\n    });\n  });\n\n  setTimeout(function() {\n    // runs with the default context, because nested contexts have ended\n    console.log(writer.get('value')); // prints 0\n    bindTest(); // prints 2\n  }, 1000);\n}\n\n\n```\n\n## Class: Namespaced\n\n","readmeFilename":"README.md"}