passenger 5.0.21 → 5.0.22

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (203) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +38 -2
  5. data/CONTRIBUTORS +3 -0
  6. data/README.md +5 -1
  7. data/bin/passenger-status +2 -7
  8. data/build/agent.rb +2 -0
  9. data/build/cxx_dependency_map.rb +1464 -162
  10. data/build/node_tests.rb +1 -1
  11. data/build/packaging.rb +1 -1
  12. data/dev/ci/run_travis.sh +1 -1
  13. data/dev/vagrant/provision.sh +1 -1
  14. data/npm-shrinkwrap.json +635 -125
  15. data/package.json +1 -1
  16. data/resources/templates/standalone/config.erb +33 -161
  17. data/resources/templates/standalone/global.erb +15 -0
  18. data/resources/templates/standalone/http.erb +40 -0
  19. data/resources/templates/standalone/mass_deployment_default_server.erb +11 -0
  20. data/resources/templates/standalone/rails_asset_pipeline.erb +22 -0
  21. data/resources/templates/standalone/server.erb +58 -0
  22. data/src/agent/Core/ApiServer.h +37 -32
  23. data/src/agent/Core/ApplicationPool/BasicGroupInfo.h +1 -1
  24. data/src/agent/Core/ApplicationPool/BasicProcessInfo.h +6 -0
  25. data/src/agent/Core/ApplicationPool/Common.h +1 -1
  26. data/src/agent/Core/ApplicationPool/Group/OutOfBandWork.cpp +1 -1
  27. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +4 -0
  28. data/src/agent/Core/ApplicationPool/Implementation.cpp +2 -2
  29. data/src/agent/Core/ApplicationPool/Options.h +18 -1
  30. data/src/agent/Core/ApplicationPool/Pool.h +1 -1
  31. data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +6 -6
  32. data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +3 -3
  33. data/src/agent/Core/ApplicationPool/Pool/InitializationAndShutdown.cpp +1 -1
  34. data/src/agent/Core/ApplicationPool/Pool/Miscellaneous.cpp +6 -0
  35. data/src/agent/Core/ApplicationPool/Process.h +6 -1
  36. data/src/agent/Core/ApplicationPool/Socket.h +9 -12
  37. data/src/agent/Core/Controller.h +422 -0
  38. data/src/agent/Core/{RequestHandler → Controller}/AppResponse.h +2 -0
  39. data/src/agent/Core/{RequestHandler → Controller}/BufferBody.cpp +27 -5
  40. data/src/agent/Core/{RequestHandler → Controller}/CheckoutSession.cpp +61 -31
  41. data/src/agent/Core/{RequestHandler → Controller}/Client.h +5 -2
  42. data/src/agent/Core/{RequestHandler → Controller}/ForwardResponse.cpp +93 -42
  43. data/src/agent/Core/{RequestHandler → Controller}/Hooks.cpp +107 -60
  44. data/src/agent/Core/Controller/Implementation.cpp +38 -0
  45. data/src/agent/Core/{RequestHandler → Controller}/InitRequest.cpp +134 -80
  46. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +165 -0
  47. data/src/agent/Core/{RequestHandler/Utils.cpp → Controller/InternalUtils.cpp} +49 -32
  48. data/src/agent/Core/Controller/Miscellaneous.cpp +116 -0
  49. data/src/agent/Core/{RequestHandler → Controller}/Request.h +6 -4
  50. data/src/agent/Core/{RequestHandler → Controller}/SendRequest.cpp +205 -130
  51. data/src/agent/Core/Controller/StateInspectionAndConfiguration.cpp +161 -0
  52. data/src/agent/Core/{RequestHandler → Controller}/TurboCaching.h +3 -0
  53. data/src/agent/Core/CoreMain.cpp +62 -51
  54. data/src/agent/Core/OptionParser.h +24 -0
  55. data/src/agent/Core/ResponseCache.h +5 -5
  56. data/src/agent/Core/SpawningKit/Config.h +2 -2
  57. data/src/agent/Core/SpawningKit/SmartSpawner.h +1 -1
  58. data/src/agent/Core/UnionStation/{Core.h → Context.h} +14 -18
  59. data/src/agent/Core/UnionStation/StopwatchLog.h +3 -2
  60. data/src/agent/Core/UnionStation/Transaction.h +7 -7
  61. data/src/agent/Shared/ApiServerUtils.h +9 -1
  62. data/src/agent/UstRouter/ApiServer.h +5 -2
  63. data/src/agent/UstRouter/Controller.h +27 -9
  64. data/src/agent/UstRouter/UstRouterMain.cpp +1 -0
  65. data/src/agent/Watchdog/ApiServer.h +5 -2
  66. data/src/apache2_module/ConfigurationCommands.cpp +7 -0
  67. data/src/apache2_module/ConfigurationFields.hpp +2 -0
  68. data/src/apache2_module/ConfigurationSetters.cpp +24 -0
  69. data/src/apache2_module/CreateDirConfig.cpp +1 -0
  70. data/src/apache2_module/Hooks.cpp +6 -5
  71. data/src/apache2_module/MergeDirConfig.cpp +7 -0
  72. data/src/apache2_module/SetHeaders.cpp +5 -0
  73. data/src/cxx_supportlib/Constants.h +5 -3
  74. data/src/cxx_supportlib/SafeLibev.h +2 -1
  75. data/src/cxx_supportlib/UnionStationFilterSupport.h +2 -1
  76. data/src/cxx_supportlib/Utils/ReleaseableScopedPointer.h +70 -0
  77. data/src/cxx_supportlib/vendor-modified/boost/libs/regex/src/regex_raw_buffer.cpp +6 -6
  78. data/src/helper-scripts/node-loader.js +59 -0
  79. data/src/nginx_module/CacheLocationConfig.c +48 -0
  80. data/src/nginx_module/ConfigurationCommands.c +20 -0
  81. data/src/nginx_module/ConfigurationFields.h +4 -0
  82. data/src/nginx_module/CreateLocationConfig.c +8 -0
  83. data/src/nginx_module/MergeLocationConfig.c +12 -0
  84. data/src/nodejs_supportlib/phusion_passenger/log_express.js +106 -0
  85. data/src/nodejs_supportlib/phusion_passenger/log_mongodb.js +203 -0
  86. data/src/nodejs_supportlib/phusion_passenger/ustreporter.js +227 -0
  87. data/src/nodejs_supportlib/phusion_passenger/ustrouter_connector.js +446 -0
  88. data/src/nodejs_supportlib/vendor-copy/codify/codify.js +44 -0
  89. data/src/nodejs_supportlib/vendor-copy/codify/package.json +29 -0
  90. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/context.js +200 -0
  91. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/glue.js +488 -0
  92. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/index.js +407 -0
  93. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/node_modules/shimmer/index.js +90 -0
  94. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/node_modules/shimmer/package.json +40 -0
  95. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/async-listener/package.json +54 -0
  96. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/listener.js +160 -0
  97. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/node_modules/shimmer/index.js +90 -0
  98. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/node_modules/shimmer/package.json +40 -0
  99. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/node_modules/emitter-listener/package.json +46 -0
  100. data/src/nodejs_supportlib/vendor-copy/continuation-local-storage/package.json +56 -0
  101. data/src/nodejs_supportlib/vendor-copy/network-byte-order/lib/index.js +102 -0
  102. data/src/nodejs_supportlib/vendor-copy/network-byte-order/package.json +51 -0
  103. data/src/nodejs_supportlib/vendor-copy/winston/LICENSE +19 -0
  104. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston.js +165 -0
  105. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/common.js +483 -0
  106. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js +62 -0
  107. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/cli-config.js +35 -0
  108. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/npm-config.js +27 -0
  109. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/syslog-config.js +31 -0
  110. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/container.js +127 -0
  111. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/exception.js +56 -0
  112. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/logger.js +701 -0
  113. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports.js +34 -0
  114. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/console.js +128 -0
  115. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/daily-rotate-file.js +601 -0
  116. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/file.js +675 -0
  117. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/http.js +232 -0
  118. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/memory.js +89 -0
  119. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/transport.js +135 -0
  120. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/webhook.js +146 -0
  121. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/LICENSE +19 -0
  122. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/lib/async.js +1283 -0
  123. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/package.json +66 -0
  124. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/support/sync-package-managers.js +53 -0
  125. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/MIT-LICENSE.txt +23 -0
  126. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/colors.js +176 -0
  127. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/custom/trap.js +45 -0
  128. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/custom/zalgo.js +104 -0
  129. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/extendStringPrototype.js +118 -0
  130. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/index.js +12 -0
  131. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/america.js +12 -0
  132. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/rainbow.js +13 -0
  133. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/random.js +8 -0
  134. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/maps/zebra.js +5 -0
  135. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/styles.js +77 -0
  136. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/lib/system/supports-colors.js +61 -0
  137. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/package.json +35 -0
  138. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/safe.js +9 -0
  139. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/themes/generic-logging.js +12 -0
  140. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/cycle.js +170 -0
  141. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/package.json +30 -0
  142. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/LICENSE +20 -0
  143. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/lib/eyes.js +236 -0
  144. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/package.json +42 -0
  145. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/LICENSE.md +11 -0
  146. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/isstream.js +27 -0
  147. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/package.json +42 -0
  148. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/LICENSE +19 -0
  149. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/lib/pkginfo.js +136 -0
  150. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/package.json +56 -0
  151. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/License +19 -0
  152. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/lib/stack-trace.js +111 -0
  153. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/package.json +33 -0
  154. data/src/nodejs_supportlib/vendor-copy/winston/package.json +87 -0
  155. data/src/ruby_supportlib/phusion_passenger.rb +3 -4
  156. data/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb +19 -2
  157. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +8 -0
  158. data/src/ruby_supportlib/phusion_passenger/config/list_instances_command.rb +2 -6
  159. data/src/ruby_supportlib/phusion_passenger/config/reopen_logs_command.rb +13 -0
  160. data/src/ruby_supportlib/phusion_passenger/config/restart_app_command.rb +3 -0
  161. data/src/ruby_supportlib/phusion_passenger/config/utils.rb +9 -7
  162. data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +8 -1
  163. data/src/ruby_supportlib/phusion_passenger/constants.rb +3 -1
  164. data/src/ruby_supportlib/phusion_passenger/native_support.rb +20 -4
  165. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +8 -0
  166. data/src/ruby_supportlib/phusion_passenger/packaging.rb +1 -0
  167. data/src/ruby_supportlib/phusion_passenger/platform_info/apache_detector.rb +1 -1
  168. data/src/ruby_supportlib/phusion_passenger/platform_info/operating_system.rb +11 -4
  169. data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  170. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +647 -0
  171. data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +229 -15
  172. data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +35 -323
  173. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +36 -12
  174. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +123 -14
  175. data/src/ruby_supportlib/phusion_passenger/standalone/status_command.rb +32 -17
  176. data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +32 -21
  177. data/src/ruby_supportlib/phusion_passenger/standalone/version_command.rb +5 -5
  178. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/README.md +2 -2
  179. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/Rakefile +5 -1
  180. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +68 -24
  181. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +9 -1
  182. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +9 -7
  183. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +3 -2
  184. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter/basics.rb +8 -5
  185. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +395 -0
  186. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +10 -7
  187. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +14 -0
  188. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/version_data.rb +2 -2
  189. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml +4 -2
  190. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.example +2 -2
  191. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis +2 -2
  192. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/ruby_versions.yml.travis-with-sudo +16 -0
  193. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile +1 -1
  194. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/Gemfile.lock +2 -2
  195. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/README.md +1 -1
  196. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails.rb +44 -17
  197. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/active_support_cache_subscriber.rb +16 -7
  198. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/lib/union_station_hooks_rails/version_data.rb +2 -2
  199. data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails/union_station_hooks_rails.gemspec +1 -1
  200. metadata +99 -16
  201. metadata.gz.asc +7 -7
  202. data/resources/oss-binaries.phusionpassenger.com.crt +0 -248
  203. data/src/agent/Core/RequestHandler.h +0 -471
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "shimmer",
3
+ "version": "1.0.0",
4
+ "description": "Safe(r) monkeypatching for JavaScript.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "tap test/*.tap.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/othiym23/shimmer.git"
12
+ },
13
+ "keywords": [
14
+ "monkeypatch",
15
+ "swizzle",
16
+ "wrapping",
17
+ "danger",
18
+ "hmm",
19
+ "shim"
20
+ ],
21
+ "author": {
22
+ "name": "Forrest L Norvell",
23
+ "email": "ogd@aoaioxxysz.net"
24
+ },
25
+ "license": "BSD",
26
+ "devDependencies": {
27
+ "tap": "~0.4.3",
28
+ "sinon": "~1.7.2"
29
+ },
30
+ "readme": "## Safer monkeypatching for Node.js\n\n`shimmer` does a bunch of the work necessary to wrap other methods in\na wrapper you provide:\n\n```javascript\nvar http = require('http');\nvar shimmer = require('shimmer');\n\nshimmer.wrap(http, 'request', function (original) {\n return function () {\n console.log(\"Starting request!\");\n var returned = original.apply(this, arguments)\n console.log(\"Done setting up request -- OH YEAH!\");\n return returned;\n };\n});\n```\n\n### Mandatory disclaimer\n\nThere are times when it's necessary to monkeypatch default behavior in\nJavaScript and Node. However, changing the behavior of the runtime on the fly\nis rarely a good idea, and you should be using this module because you need to,\nnot because it seems like fun.\n\n### API\n\nAll monkeypatched functions have an attribute, `__wrapped`, set to true on\nthem.\n\n#### shimmer(options)\n\nIf you pass in an options object containing a function labeled `logger`,\n`shimmer` will use it instead of the logger, which defaults to `console.error`.\n`shimmer` is built to be as unobtrusive as possible and has no need to run\nasynchronously, so it defaults to logging when things fail, instead of\nthrowing.\n\n#### shimmer.wrap(nodule, name, wrapper)\n\n`shimmer` monkeypatches in place, so it expects to be passed an object.\nIt accepts either instances, prototypes, or the results of calling\n`require`. `name` must be the string key for the field's name on the\nobject.\n\n`wrapper` is a function that takes a single parameter, which is the original\nfunction to be monkeypatched. `shimmer` assumes that you're adding behavior\nto the original method, and not replacing it outright. If you *are* replacing\nthe original function, feel free to ignore the passed-in function.\n\nIf you *aren't* discarding the original, remember these tips:\n\n* call the original with something like `original.apply(this, arguments)`,\n unless your reason for monkeypatching is to transform the arguments.\n* always capture and return the return value coming from the original function.\n Today's null-returning callback is tomorrow's error-code returning callback.\n* Don't make an asynchronous function synchronous and vice versa.\n\n#### shimmer.massWrap(nodules, names, wrapper)\n\nJust like `wrap`, with the addition that you can wrap multiple methods on\nmultiple modules. Note that this function expects the list of functions to be\nmonkeypatched on all of the modules to be the same.\n\n#### shimmer.unwrap(nodule, name)\n\nA convenience function for restoring the function back the way it was before\nyou started. Won't unwrap if somebody else has monkeypatched the function after\nyou (but will log in that case). Won't throw if you try to double-unwrap a\nfunction (but will log).\n\n#### shimmer.wrapEmitter(emitter, mark, prepare)\n\nWrap an EventEmitter's event listeners. Each listener will be passed to\n`mark` when it is registered with `.addListener()` or `.on()`, and then\neach listener is passed to `prepare` to be wrapped before it's called\nby the `.emit()` call. `wrapListener` deals with the single listener\nvs array of listeners logic, and also ensures that edge cases like\n`.removeListener()` being called from within an `.emit()` for the same\nevent type is handled properly.\n\nThe wrapped EE can be restored to its pristine state by using\nemitter.__unwrap(), but this should only be used if you *really* know\nwhat you're doing.\n",
31
+ "readmeFilename": "README.md",
32
+ "bugs": {
33
+ "url": "https://github.com/othiym23/shimmer/issues"
34
+ },
35
+ "homepage": "https://github.com/othiym23/shimmer",
36
+ "_id": "shimmer@1.0.0",
37
+ "_shasum": "49c2d71c678360b802be18b278382d1cbb805c39",
38
+ "_from": "shimmer@1.0.0",
39
+ "_resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.0.0.tgz"
40
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "async-listener",
3
+ "version": "0.5.6",
4
+ "description": "Polyfill exporting trevnorris's 0.11+ asyncListener API.",
5
+ "author": {
6
+ "name": "Forrest L Norvell",
7
+ "email": "ogd@aoaioxxysz.net"
8
+ },
9
+ "contributors": [
10
+ {
11
+ "name": "Tim Caswell",
12
+ "email": "tim@creationix.com"
13
+ },
14
+ {
15
+ "name": "Forrest L Norvell",
16
+ "email": "ogd@aoaioxxysz.net"
17
+ }
18
+ ],
19
+ "main": "index.js",
20
+ "scripts": {
21
+ "test": "tap test/*.tap.js"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/othiym23/async-listener.git"
26
+ },
27
+ "keywords": [
28
+ "polyfill",
29
+ "shim",
30
+ "zesty",
31
+ "crazed",
32
+ "experimental"
33
+ ],
34
+ "license": "BSD-2-Clause",
35
+ "bugs": {
36
+ "url": "https://github.com/othiym23/async-listener/issues"
37
+ },
38
+ "engines": {
39
+ "node": "<=0.11.8 || >0.11.10"
40
+ },
41
+ "dependencies": {
42
+ "shimmer": "1.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "tap": "^0.7.1"
46
+ },
47
+ "readme": "[![NPM](https://nodei.co/npm/async-listener.png?downloads=true&stars=true)](https://nodei.co/npm/async-listener/)\n\n# process.addAsyncListener polyfill\n\nThis is an implementation of Trevor Norris's\nprocess.{addAsyncListener,removeAsyncListener} API for adding behavior to async\ncalls. You can see his implementation (currently a work in progress) on\n[Node.js core pull request #6011](https://github.com/joyent/node/pull/6011).\nThis polyfill / shim is intended for use in versions of Node prior to whatever\nversion of Node in which Trevor's changes finally land (anticipated at the time\nof this writing as 0.11.7).\n\nHere's his documentation of the intended API, which will probably get cleaned up\nhere later:\n\n## createAsyncListener(callbacks[, initialStorage])\n\n* `callbacks` {Object}\n* `initialStorage` {Value}\n\nReturns a constructed `AsyncListener` object. Which can then be passed to\n`process.addAsyncListener()` and `process.removeAsyncListener()`. Each\nfunction parameter is as follows:\n\n1. `callbacks`: An `Object` which may contain four optional fields:\n * `create`: A `function (storage)` that is called when an asynchronous event\n is queued. Recives the `storage` attached to the listner. `storage` can be\n created by passing an `initialStorage` argument during costruction, or by\n returning a `Value` from `create` which will be attached to the listner\n and overwrite the `initialStorage`.\n * `before`: A `function (context, storage)` that is called immediately\n before the asynchronous callback is about to run. It will be passed both\n the `context` (i.e. `this`) of the calling function and the `storage`.\n * `after`: A `function (context, storage)` called immediately after the\n asynchronous event's callback is run. Note that if the event's callback\n throws during execution this will not be called.\n * `error`: A `function (storage, error)` called if the event's callback\n threw. If `error` returns `true` then Node will assume the error has been\n properly handled and resume execution normally.\n1. `initialStorage`: A `Value` (i.e. anything) that will be, by default,\n attached to all new event instances. This will be overwritten if a `Value`\n is returned by `create()`.\n\n\n## addAsyncListener(callbacks[, initialStorage])\n## addAsyncListener(asyncListener)\n\nReturns a constructed `AsyncListener` object and immediately adds it to the\nlistening queue.\n\n## removeAsyncListener(asyncListener)\n\nRemoves the `asyncListener` from the listening queue.\n",
48
+ "readmeFilename": "README.md",
49
+ "homepage": "https://github.com/othiym23/async-listener",
50
+ "_id": "async-listener@0.5.6",
51
+ "_shasum": "0c5f7dfb7d5ba657098f3ca5d7be693f720e09f9",
52
+ "_from": "async-listener@^0.5.0",
53
+ "_resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.5.6.tgz"
54
+ }
@@ -0,0 +1,160 @@
1
+ 'use strict';
2
+
3
+ var shimmer = require('shimmer');
4
+ var wrap = shimmer.wrap;
5
+ var unwrap = shimmer.unwrap;
6
+
7
+ // Default to complaining loudly when things don't go according to plan.
8
+ // dunderscores are boring
9
+ var SYMBOL = 'wrap@before';
10
+
11
+ function _process(self, listeners) {
12
+ var l = listeners.length;
13
+ for (var p = 0; p < l; p++) {
14
+ var listener = listeners[p];
15
+ // set up the listener so that onEmit can do whatever it needs
16
+ var before = self[SYMBOL];
17
+ if (typeof before === 'function') {
18
+ before(listener);
19
+ }
20
+ else if (Array.isArray(before)) {
21
+ var length = before.length;
22
+ for (var i = 0; i < length; i++) before[i](listener);
23
+ }
24
+ }
25
+ }
26
+
27
+ function _listeners(self, event) {
28
+ var listeners;
29
+ listeners = self._events && self._events[event];
30
+ if (!Array.isArray(listeners)) {
31
+ if (listeners) {
32
+ listeners = [listeners];
33
+ }
34
+ else {
35
+ listeners = [];
36
+ }
37
+ }
38
+
39
+ return listeners;
40
+ }
41
+
42
+ function _findAndProcess(self, event, before) {
43
+ var after = _listeners(self, event);
44
+ var unprocessed = after.filter(function(fn) { return before.indexOf(fn) === -1; });
45
+ if (unprocessed.length > 0) _process(self, unprocessed);
46
+ }
47
+
48
+ function _wrap(unwrapped, visit) {
49
+ if (!unwrapped) return;
50
+
51
+ var wrapped = unwrapped;
52
+ if (typeof unwrapped === 'function') {
53
+ wrapped = visit(unwrapped);
54
+ }
55
+ else if (Array.isArray(unwrapped)) {
56
+ wrapped = [];
57
+ for (var i = 0; i < unwrapped.length; i++) {
58
+ wrapped[i] = visit(unwrapped[i]);
59
+ }
60
+ }
61
+ return wrapped;
62
+ }
63
+
64
+ module.exports = function wrapEmitter(emitter, onAddListener, onEmit) {
65
+ if (!emitter || !emitter.on || !emitter.addListener ||
66
+ !emitter.removeListener || !emitter.emit) {
67
+ throw new Error("can only wrap real EEs");
68
+ }
69
+
70
+ if (!onAddListener) throw new Error("must have function to run on listener addition");
71
+ if (!onEmit) throw new Error("must have function to wrap listeners when emitting");
72
+
73
+ /* Attach a context to a listener, and make sure that this hook stays
74
+ * attached to the emitter forevermore.
75
+ */
76
+ function adding(on) {
77
+ return function added(event, listener) {
78
+ var existing = _listeners(this, event);
79
+
80
+ try {
81
+ var returned = on.call(this, event, listener);
82
+ _findAndProcess(this, event, existing);
83
+ return returned;
84
+ }
85
+ finally {
86
+ // old-style streaming overwrites .on and .addListener, so rewrap
87
+ if (!this.on.__wrapped) wrap(this, 'on', adding);
88
+ if (!this.addListener.__wrapped) wrap(this, 'addListener', adding);
89
+ }
90
+ };
91
+ }
92
+
93
+ function emitting(emit) {
94
+ return function emitted(event) {
95
+ if (!this._events || !this._events[event]) return emit.apply(this, arguments);
96
+
97
+ var unwrapped = this._events[event];
98
+
99
+ /* Ensure that if removeListener gets called, it's working with the
100
+ * unwrapped listeners.
101
+ */
102
+ function remover(removeListener) {
103
+ return function removed() {
104
+ this._events[event] = unwrapped;
105
+ try {
106
+ return removeListener.apply(this, arguments);
107
+ }
108
+ finally {
109
+ unwrapped = this._events[event];
110
+ this._events[event] = _wrap(unwrapped, onEmit);
111
+ }
112
+ };
113
+ }
114
+ wrap(this, 'removeListener', remover);
115
+
116
+ try {
117
+ /* At emit time, ensure that whatever else is going on, removeListener will
118
+ * still work while at the same time running whatever hooks are necessary to
119
+ * make sure the listener is run in the correct context.
120
+ */
121
+ this._events[event] = _wrap(unwrapped, onEmit);
122
+ return emit.apply(this, arguments);
123
+ }
124
+ finally {
125
+ /* Ensure that regardless of what happens when preparing and running the
126
+ * listeners, the status quo ante is restored before continuing.
127
+ */
128
+ unwrap(this, 'removeListener');
129
+ this._events[event] = unwrapped;
130
+ }
131
+ };
132
+ }
133
+
134
+ // support multiple onAddListeners
135
+ if (!emitter[SYMBOL]) {
136
+ emitter[SYMBOL] = onAddListener;
137
+ }
138
+ else if (typeof emitter[SYMBOL] === 'function') {
139
+ emitter[SYMBOL] = [emitter[SYMBOL], onAddListener];
140
+ }
141
+ else if (Array.isArray(emitter[SYMBOL])) {
142
+ emitter[SYMBOL].push(onAddListener);
143
+ }
144
+
145
+ // only wrap the core functions once
146
+ if (!emitter.__wrapped) {
147
+ wrap(emitter, 'addListener', adding);
148
+ wrap(emitter, 'on', adding);
149
+ wrap(emitter, 'emit', emitting);
150
+
151
+ emitter.__unwrap = function () {
152
+ unwrap(emitter, 'addListener');
153
+ unwrap(emitter, 'on');
154
+ unwrap(emitter, 'emit');
155
+ delete emitter[SYMBOL];
156
+ delete emitter.__wrapped;
157
+ };
158
+ emitter.__wrapped = true;
159
+ }
160
+ };
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ function isFunction(funktion) {
4
+ return funktion && {}.toString.call(funktion) === '[object Function]';
5
+ }
6
+
7
+ // Default to complaining loudly when things don't go according to plan.
8
+ var logger = console.error.bind(console);
9
+
10
+ // Keep initialization idempotent.
11
+ function shimmer(options) {
12
+ if (options && options.logger) {
13
+ if (!isFunction(options.logger)) logger("new logger isn't a function, not replacing");
14
+ else logger = options.logger;
15
+ }
16
+ }
17
+
18
+ function wrap(nodule, name, wrapper) {
19
+ if (!nodule || !nodule[name]) {
20
+ logger("no original function " + name + " to wrap");
21
+ return;
22
+ }
23
+
24
+ if (!wrapper) {
25
+ logger("no wrapper function");
26
+ logger((new Error()).stack);
27
+ return;
28
+ }
29
+
30
+ if (!isFunction(nodule[name]) || !isFunction(wrapper)) {
31
+ logger("original object and wrapper must be functions");
32
+ return;
33
+ }
34
+
35
+ var original = nodule[name]
36
+ , wrapped = wrapper(original)
37
+ ;
38
+
39
+ wrapped.__original = original;
40
+ wrapped.__unwrap = function () {
41
+ if (nodule[name] === wrapped) nodule[name] = original;
42
+ };
43
+ wrapped.__wrapped = true;
44
+
45
+ nodule[name] = wrapped;
46
+
47
+ return wrapped;
48
+ }
49
+
50
+ function massWrap(nodules, names, wrapper) {
51
+ if (!nodules) {
52
+ logger("must provide one or more modules to patch");
53
+ logger((new Error()).stack);
54
+ return;
55
+ } else if (!Array.isArray(nodules)) {
56
+ nodules = [nodules];
57
+ }
58
+
59
+ if (!(names && Array.isArray(names))) {
60
+ logger("must provide one or more functions to wrap on modules");
61
+ return;
62
+ }
63
+
64
+ nodules.forEach(function (nodule) {
65
+ names.forEach(function (name) {
66
+ wrap(nodule, name, wrapper);
67
+ });
68
+ });
69
+ }
70
+
71
+ function unwrap(nodule, name) {
72
+ if (!nodule || !nodule[name]) {
73
+ logger("no function to unwrap.");
74
+ logger((new Error()).stack);
75
+ return;
76
+ }
77
+
78
+ if (!nodule[name].__unwrap) {
79
+ logger("no original to unwrap to -- has " + name + " already been unwrapped?");
80
+ }
81
+ else {
82
+ return nodule[name].__unwrap();
83
+ }
84
+ }
85
+
86
+ shimmer.wrap = wrap;
87
+ shimmer.massWrap = massWrap;
88
+ shimmer.unwrap = unwrap;
89
+
90
+ module.exports = shimmer;
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "shimmer",
3
+ "version": "1.0.0",
4
+ "description": "Safe(r) monkeypatching for JavaScript.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "tap test/*.tap.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/othiym23/shimmer.git"
12
+ },
13
+ "keywords": [
14
+ "monkeypatch",
15
+ "swizzle",
16
+ "wrapping",
17
+ "danger",
18
+ "hmm",
19
+ "shim"
20
+ ],
21
+ "author": {
22
+ "name": "Forrest L Norvell",
23
+ "email": "ogd@aoaioxxysz.net"
24
+ },
25
+ "license": "BSD",
26
+ "devDependencies": {
27
+ "tap": "~0.4.3",
28
+ "sinon": "~1.7.2"
29
+ },
30
+ "readme": "## Safer monkeypatching for Node.js\n\n`shimmer` does a bunch of the work necessary to wrap other methods in\na wrapper you provide:\n\n```javascript\nvar http = require('http');\nvar shimmer = require('shimmer');\n\nshimmer.wrap(http, 'request', function (original) {\n return function () {\n console.log(\"Starting request!\");\n var returned = original.apply(this, arguments)\n console.log(\"Done setting up request -- OH YEAH!\");\n return returned;\n };\n});\n```\n\n### Mandatory disclaimer\n\nThere are times when it's necessary to monkeypatch default behavior in\nJavaScript and Node. However, changing the behavior of the runtime on the fly\nis rarely a good idea, and you should be using this module because you need to,\nnot because it seems like fun.\n\n### API\n\nAll monkeypatched functions have an attribute, `__wrapped`, set to true on\nthem.\n\n#### shimmer(options)\n\nIf you pass in an options object containing a function labeled `logger`,\n`shimmer` will use it instead of the logger, which defaults to `console.error`.\n`shimmer` is built to be as unobtrusive as possible and has no need to run\nasynchronously, so it defaults to logging when things fail, instead of\nthrowing.\n\n#### shimmer.wrap(nodule, name, wrapper)\n\n`shimmer` monkeypatches in place, so it expects to be passed an object.\nIt accepts either instances, prototypes, or the results of calling\n`require`. `name` must be the string key for the field's name on the\nobject.\n\n`wrapper` is a function that takes a single parameter, which is the original\nfunction to be monkeypatched. `shimmer` assumes that you're adding behavior\nto the original method, and not replacing it outright. If you *are* replacing\nthe original function, feel free to ignore the passed-in function.\n\nIf you *aren't* discarding the original, remember these tips:\n\n* call the original with something like `original.apply(this, arguments)`,\n unless your reason for monkeypatching is to transform the arguments.\n* always capture and return the return value coming from the original function.\n Today's null-returning callback is tomorrow's error-code returning callback.\n* Don't make an asynchronous function synchronous and vice versa.\n\n#### shimmer.massWrap(nodules, names, wrapper)\n\nJust like `wrap`, with the addition that you can wrap multiple methods on\nmultiple modules. Note that this function expects the list of functions to be\nmonkeypatched on all of the modules to be the same.\n\n#### shimmer.unwrap(nodule, name)\n\nA convenience function for restoring the function back the way it was before\nyou started. Won't unwrap if somebody else has monkeypatched the function after\nyou (but will log in that case). Won't throw if you try to double-unwrap a\nfunction (but will log).\n\n#### shimmer.wrapEmitter(emitter, mark, prepare)\n\nWrap an EventEmitter's event listeners. Each listener will be passed to\n`mark` when it is registered with `.addListener()` or `.on()`, and then\neach listener is passed to `prepare` to be wrapped before it's called\nby the `.emit()` call. `wrapListener` deals with the single listener\nvs array of listeners logic, and also ensures that edge cases like\n`.removeListener()` being called from within an `.emit()` for the same\nevent type is handled properly.\n\nThe wrapped EE can be restored to its pristine state by using\nemitter.__unwrap(), but this should only be used if you *really* know\nwhat you're doing.\n",
31
+ "readmeFilename": "README.md",
32
+ "bugs": {
33
+ "url": "https://github.com/othiym23/shimmer/issues"
34
+ },
35
+ "homepage": "https://github.com/othiym23/shimmer",
36
+ "_id": "shimmer@1.0.0",
37
+ "_shasum": "49c2d71c678360b802be18b278382d1cbb805c39",
38
+ "_from": "shimmer@1.0.0",
39
+ "_resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.0.0.tgz"
40
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "emitter-listener",
3
+ "version": "1.0.1",
4
+ "description": "(Meta)observability for EventEmitters.",
5
+ "main": "listener.js",
6
+ "directories": {
7
+ "test": "test"
8
+ },
9
+ "scripts": {
10
+ "test": "tap test/*.tap.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/othiym23/emitter-listener.git"
15
+ },
16
+ "keywords": [
17
+ "wow",
18
+ "such",
19
+ "introspection",
20
+ "amaze",
21
+ "listener",
22
+ "so",
23
+ "observe"
24
+ ],
25
+ "author": {
26
+ "name": "Forrest L Norvell",
27
+ "email": "ogd@aoaioxxysz.net"
28
+ },
29
+ "license": "BSD-2-Clause",
30
+ "bugs": {
31
+ "url": "https://github.com/othiym23/emitter-listener/issues"
32
+ },
33
+ "homepage": "https://github.com/othiym23/emitter-listener",
34
+ "devDependencies": {
35
+ "tap": "~0.4.6"
36
+ },
37
+ "dependencies": {
38
+ "shimmer": "1.0.0"
39
+ },
40
+ "readme": "## Add dynamic instrumentation to emitters\n\n`shimmer` does a bunch of the work necessary to wrap other methods in\na wrapper you provide:\n\n```javascript\nvar EventEmitter = require('events').EventEmitter;\nvar wrapEmitter = require('emitter-listener');\n\nvar ee = new EventEmitter();\n\nvar id = 0;\n\nwrapEmitter(\n ee,\n function mark(listener) {\n listener.id = id++;\n },\n function prepare(listener) {\n console.log('listener id is %d', listener.id);\n }\n);\n```\n\n### Mandatory disclaimer\n\nThere are times when it's necessary to monkeypatch default behavior in\nJavaScript and Node. However, changing the behavior of the runtime on the fly\nis rarely a good idea, and you should be using this module because you need to,\nnot because it seems like fun.\n\n#### wrapEmitter(emitter, mark, prepare)\n\nWrap an EventEmitter's event listeners. Each listener will be passed to\n`mark` when it is registered with `.addListener()` or `.on()`, and then\neach listener is passed to `prepare` to be wrapped before it's called\nby the `.emit()` call. `wrapListener` deals with the single listener\nvs array of listeners logic, and also ensures that edge cases like\n`.removeListener()` being called from within an `.emit()` for the same\nevent type is handled properly.\n\nThe wrapped EE can be restored to its pristine state by using\nemitter.__unwrap(), but this should only be used if you *really* know\nwhat you're doing.\n",
41
+ "readmeFilename": "README.md",
42
+ "_id": "emitter-listener@1.0.1",
43
+ "_shasum": "b2499ea6e58230a52c268d5df261eecd9f10fe97",
44
+ "_from": "emitter-listener@^1.0.1",
45
+ "_resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.0.1.tgz"
46
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "continuation-local-storage",
3
+ "version": "3.1.4",
4
+ "description": "userland implementation of https://github.com/joyent/node/issues/5243",
5
+ "main": "context.js",
6
+ "directories": {
7
+ "test": "test"
8
+ },
9
+ "scripts": {
10
+ "test": "tap test/*.tap.js"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/othiym23/node-continuation-local-storage.git"
15
+ },
16
+ "keywords": [
17
+ "threading",
18
+ "shared",
19
+ "context",
20
+ "domains",
21
+ "tracing",
22
+ "logging"
23
+ ],
24
+ "author": {
25
+ "name": "Forrest L Norvell",
26
+ "email": "ogd@aoaioxxysz.net"
27
+ },
28
+ "contributors": [
29
+ {
30
+ "name": "Tim Caswell",
31
+ "email": "tim@creationix.com"
32
+ },
33
+ {
34
+ "name": "Forrest L Norvell",
35
+ "email": "ogd@aoaioxxysz.net"
36
+ }
37
+ ],
38
+ "license": "BSD",
39
+ "devDependencies": {
40
+ "tap": "^0.7.1"
41
+ },
42
+ "dependencies": {
43
+ "async-listener": "^0.5.0",
44
+ "emitter-listener": "^1.0.1"
45
+ },
46
+ "readme": "[![NPM](https://nodei.co/npm/continuation-local-storage.png?downloads=true&stars=true)](https://nodei.co/npm/continuation-local-storage/)\n\n# Continuation-Local Storage\n\nContinuation-local storage works like thread-local storage in threaded\nprogramming, but is based on chains of Node-style callbacks instead of threads.\nThe standard Node convention of functions calling functions is very similar to\nsomething called [\"continuation-passing style\"][cps] in functional programming,\nand the name comes from the way this module allows you to set and get values\nthat are scoped to the lifetime of these chains of function calls.\n\nSuppose you're writing a module that fetches a user and adds it to a session\nbefore calling a function passed in by a user to continue execution:\n\n```javascript\n// setup.js\n\nvar createNamespace = require('continuation-local-storage').createNamespace;\nvar session = createNamespace('my session');\n\nvar db = require('./lib/db.js');\n\nfunction start(options, next) {\n db.fetchUserById(options.id, function (error, user) {\n if (error) return next(error);\n\n session.set('user', user);\n\n next();\n });\n}\n```\n\nLater on in the process of turning that user's data into an HTML page, you call\nanother function (maybe defined in another module entirely) that wants to fetch\nthe value you set earlier:\n\n```javascript\n// send_response.js\n\nvar getNamespace = require('continuation-local-storage').getNamespace;\nvar session = getNamespace('my session');\n\nvar render = require('./lib/render.js')\n\nfunction finish(response) {\n var user = session.get('user');\n render({user: user}).pipe(response);\n}\n```\n\nWhen you set values in continuation-local storage, those values are accessible\nuntil all functions called from the original function – synchronously or\nasynchronously – have finished executing. This includes callbacks passed to\n`process.nextTick` and the [timer functions][] ([setImmediate][],\n[setTimeout][], and [setInterval][]), as well as callbacks passed to\nasynchronous functions that call native functions (such as those exported from\nthe `fs`, `dns`, `zlib` and `crypto` modules).\n\nA simple rule of thumb is anywhere where you might have set a property on the\n`request` or `response` objects in an HTTP handler, you can (and should) now\nuse continuation-local storage. This API is designed to allow you extend the\nscope of a variable across a sequence of function calls, but with values\nspecific to each sequence of calls.\n\nValues are grouped into namespaces, created with `createNamespace()`. Sets of\nfunction calls are grouped together by calling them within the function passed\nto `.run()` on the namespace object. Calls to `.run()` can be nested, and each\nnested context this creates has its own copy of the set of values from the\nparent context. When a function is making multiple asynchronous calls, this\nallows each child call to get, set, and pass along its own context without\noverwriting the parent's.\n\nA simple, annotated example of how this nesting behaves:\n\n```javascript\nvar createNamespace = require('contination-local-storage').createNamespace;\n\nvar writer = createNamespace('writer');\nwriter.run(function () {\n writer.set('value', 0);\n\n requestHandler();\n});\n\nfunction requestHandler() {\n writer.run(function(outer) {\n // writer.get('value') returns 0\n // outer.value is 0\n writer.set('value', 1);\n // writer.get('value') returns 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 // inner.value is 1\n writer.set('value', 2);\n // writer.get('value') returns 2\n // outer.value is 1\n // inner.value is 2\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 }, 1000);\n}\n```\n\n## cls.createNamespace(name)\n\n* return: {Namespace}\n\nEach application wanting to use continuation-local values should create its own\nnamespace. Reading from (or, more significantly, writing to) namespaces that\ndon't belong to you is a faux pas.\n\n## cls.getNamespace(name)\n\n* return: {Namespace}\n\nLook up an existing namespace.\n\n## cls.destroyNamespace(name)\n\nDispose of an existing namespace. WARNING: be sure to dispose of any references\nto destroyed namespaces in your old code, as contexts associated with them will\nno longer be propagated.\n\n## cls.reset()\n\nCompletely reset all continuation-local storage namespaces. WARNING: while this\nwill stop the propagation of values in any existing namespaces, if there are\nremaining references to those namespaces in code, the associated storage will\nstill be reachable, even though the associated state is no longer being updated.\nMake sure you clean up any references to destroyed namespaces yourself.\n\n## process.namespaces\n\n* return: dictionary of {Namespace} objects\n\nContinuation-local storage has a performance cost, and so it isn't enabled\nuntil the module is loaded for the first time. Once the module is loaded, the\ncurrent set of namespaces is available in `process.namespaces`, so library code\nthat wants to use continuation-local storage only when it's active should test\nfor the existence of `process.namespaces`.\n\n## Class: Namespace\n\nApplication-specific namespaces group values local to the set of functions\nwhose calls originate from a callback passed to `namespace.run()` or\n`namespace.bind()`.\n\n### namespace.active\n\n* return: the currently active context on a namespace\n\n### namespace.set(key, value)\n\n* return: `value`\n\nSet a value on the current continuation context. Must be set within an active\ncontinuation chain started with `namespace.run()` or `namespace.bind()`.\n\n### namespace.get(key)\n\n* return: the requested value, or `undefined`\n\nLook up a value on the current continuation context. Recursively searches from\nthe innermost to outermost nested continuation context for a value associated\nwith a given key. Must be set within an active continuation chain started with\n`namespace.run()` or `namespace.bind()`.\n\n### namespace.run(callback)\n\n* return: the context associated with that callback\n\nCreate a new context on which values can be set or read. Run all the functions\nthat are called (either directly, or indirectly through asynchronous functions\nthat take callbacks themselves) from the provided callback within the scope of\nthat namespace. The new context is passed as an argument to the callback\nwhen it's called.\n\n### namespace.bind(callback, [context])\n\n* return: a callback wrapped up in a context closure\n\nBind a function to the specified namespace. Works analogously to\n`Function.bind()` or `domain.bind()`. If context is omitted, it will default to\nthe currently active context in the namespace, or create a new context if none\nis currently defined.\n\n### namespace.bindEmitter(emitter)\n\nBind an EventEmitter to a namespace. Operates similarly to `domain.add`, with a\nless generic name and the additional caveat that unlike domains, namespaces\nnever implicitly bind EventEmitters to themselves when they're created within\nthe context of an active namespace.\n\nThe most likely time you'd want to use this is when you're using Express or\nConnect and want to make sure your middleware execution plays nice with CLS, or\nare doing other things with HTTP listeners:\n\n```javascript\nhttp.createServer(function (req, res) {\n writer.add(req);\n writer.add(res);\n\n // do other stuff, some of which is asynchronous\n});\n```\n\n### namespace.createContext()\n\n* return: a context cloned from the currently active context\n\nUse this with `namespace.bind()`, if you want to have a fresh context at invocation time,\nas opposed to binding time:\n\n```javascript\nfunction doSomething(p) {\n console.log(\"%s = %s\", p, ns.get(p));\n}\n\nfunction bindLater(callback) {\n return writer.bind(callback, writer.createContext());\n}\n\nsetInterval(function () {\n var bound = bindLater(doSomething);\n bound('test');\n}, 100);\n```\n\n## context\n\nA context is a plain object created using the enclosing context as its prototype.\n\n[timer functions]: timers.html\n[setImmediate]: timers.html#timers_setimmediate_callback_arg\n[setTimeout]: timers.html#timers_settimeout_callback_delay_arg\n[setInterval]: timers.html#timers_setinterval_callback_delay_arg\n[cps]: http://en.wikipedia.org/wiki/Continuation-passing_style\n",
47
+ "readmeFilename": "README.md",
48
+ "bugs": {
49
+ "url": "https://github.com/othiym23/node-continuation-local-storage/issues"
50
+ },
51
+ "homepage": "https://github.com/othiym23/node-continuation-local-storage",
52
+ "_id": "continuation-local-storage@3.1.4",
53
+ "_shasum": "cd9d604853ef17b4527d006f7b906e3e7375a2e1",
54
+ "_from": "continuation-local-storage@^3.1.4",
55
+ "_resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.1.4.tgz"
56
+ }