Created
February 16, 2017 10:39
-
-
Save karlhorky/f41c81a9a563c0b69e1d5303876b122d to your computer and use it in GitHub Desktop.
request-local-storage global singleton
This file contains 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
// Before | |
module.exports = { | |
getNamespace: getNamespace, | |
getCountNamespaces: getCountNamespaces, | |
startRequest: startRequest, | |
bind: bind, | |
patch: patch | |
}; | |
// After (singleton in global namespace) | |
module.exports = global.continuationLocalStorage || { | |
getNamespace: getNamespace, | |
getCountNamespaces: getCountNamespaces, | |
startRequest: startRequest, | |
bind: bind, | |
patch: patch | |
}; | |
if (!global.continuationLocalStorage) { | |
global.continuationLocalStorage = module.exports; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment