Created
November 23, 2017 16:44
-
-
Save guyguyon/c0d6f5b073ea3bf38c92d0d646895c35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // node-request-context/index.js | |
| const Namespace = require('./namespace'); | |
| const namespaces = {}; | |
| function createNamespace(name) { | |
| if (namespaces[name]) { throw new Error(`A namespace for ${name} is already exists`); } | |
| const namespace = new Namespace(); | |
| namespaces[name] = namespace; | |
| createHooks(namespace); // wait for explanation below | |
| return namespace; | |
| } | |
| function getNamespace(name) { | |
| return namespaces[name]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment