{"library":"cls-hooked","type":"library","category":null,"description":"cls-hooked is a Node.js library that provides Continuation-Local Storage (CLS), a mechanism akin to thread-local storage but adapted for Node.js's asynchronous, callback-based execution model. It enables developers to maintain and implicitly pass contextual data across asynchronous operations without explicit parameter passing. The current stable version, 4.2.2, primarily targets Node.js versions `^4.7 || >=6.9 || >=7.3 || >=8.2.1`. Its key differentiator lies in its implementation, which leverages Node.js's internal, lower-level APIs: `AsyncWrap` for Node.js versions prior to v8 (an unofficial API), and the `async_hooks` API for Node.js v8.2.1 and newer (which is considered experimental). This approach distinguishes it from its predecessor, `node-continuation-local-storage`, which relied on the now-deprecated `async-listener`. The project's release cadence is largely influenced by the evolution and stability of these underlying Node.js APIs, aiming to provide a robust CLS implementation despite the experimental nature of its core dependencies.","language":"javascript","status":"active","version":"4.2.2","tags":["javascript","threading","shared","context"],"last_verified":"Wed May 27","install":[{"cmd":"npm install cls-hooked","imports":["const cls = require('cls-hooked');\nconst myNamespace = cls.createNamespace('my-app');","const cls = require('cls-hooked');\nconst myNamespace = cls.getNamespace('my-app');","const session = cls.createNamespace('my-session');\nsession.run(() => { /* contextual code here */ });"]},{"cmd":"yarn add cls-hooked","imports":[]},{"cmd":"pnpm add cls-hooked","imports":[]}],"homepage":null,"github":"https://github.com/jeff-lewis/cls-hooked","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/cls-hooked","openapi_spec":null,"status_page":null,"smithery":null,"compatibility":{"summary":{"python_range":"18–22","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"url":"https://checklist.day/v1/registry/cls-hooked/compatibility"}}