diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-04-02 08:38:48 +0300 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-04-04 13:45:39 +0300 |
commit | de0053cc3280bdf72c9010f383290f79120a1e98 (patch) | |
tree | 493fc9bd84c3d8e97342202d0a840b4fe29bdd6e /doc/api/domain.md | |
parent | 237cbe10fb82ba6ec69b14193a4a970e184306e7 (diff) | |
download | android-node-v8-de0053cc3280bdf72c9010f383290f79120a1e98.tar.gz android-node-v8-de0053cc3280bdf72c9010f383290f79120a1e98.tar.bz2 android-node-v8-de0053cc3280bdf72c9010f383290f79120a1e98.zip |
doc: fix various nits
* Replace 2 hyphens (--) by spaced m-dashes (—) as per STYLE_GUIDE.md.
* Space infix operators.
* Unify quotes in inline code spans (use only single quotes).
* Unify `* Returns:` (eliminate deviations).
* Dedupe spaces.
PR-URL: https://github.com/nodejs/node/pull/19743
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'doc/api/domain.md')
-rw-r--r-- | doc/api/domain.md | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/doc/api/domain.md b/doc/api/domain.md index 16fe3b6784..a2c7a9f90e 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -24,7 +24,7 @@ but should expect to have to migrate to a different solution in the future. Domains provide a way to handle multiple different IO operations as a -single group. If any of the event emitters or callbacks registered to a +single group. If any of the event emitters or callbacks registered to a domain emit an `'error'` event, or throw an error, then the domain object will be notified, rather than losing the context of the error in the `process.on('uncaughtException')` handler, or causing the program to @@ -52,14 +52,14 @@ time, and stop listening for new requests in that worker. In this way, `domain` usage goes hand-in-hand with the cluster module, since the master process can fork a new worker when a worker -encounters an error. For Node.js programs that scale to multiple +encounters an error. For Node.js programs that scale to multiple machines, the terminating proxy or service registry can take note of the failure, and react accordingly. For example, this is not a good idea: ```js -// XXX WARNING! BAD IDEA! +// XXX WARNING! BAD IDEA! const d = require('domain').create(); d.on('error', (er) => { @@ -115,7 +115,7 @@ if (cluster.isMaster) { const domain = require('domain'); // See the cluster documentation for more details about using - // worker processes to serve requests. How it works, caveats, etc. + // worker processes to serve requests. How it works, caveats, etc. const server = require('http').createServer((req, res) => { const d = domain.create(); @@ -125,7 +125,7 @@ if (cluster.isMaster) { // Note: We're in dangerous territory! // By definition, something unexpected occurred, // which we probably didn't want. - // Anything can happen now! Be very careful! + // Anything can happen now! Be very careful! try { // make sure we close down within 30 seconds @@ -138,7 +138,7 @@ if (cluster.isMaster) { // stop taking new requests. server.close(); - // Let the master know we're dead. This will trigger a + // Let the master know we're dead. This will trigger a // 'disconnect' in the cluster master, and then it will fork // a new worker. cluster.worker.disconnect(); @@ -167,7 +167,7 @@ if (cluster.isMaster) { server.listen(PORT); } -// This part is not important. Just an example routing thing. +// This part is not important. Just an example routing thing. // Put fancy application logic here. function handleRequest(req, res) { switch (req.url) { @@ -213,7 +213,7 @@ bound to the active domain. If they throw, then the domain will catch the error. In order to prevent excessive memory usage, Domain objects themselves -are not implicitly added as children of the active domain. If they +are not implicitly added as children of the active domain. If they were, then it would be too easy to prevent request and response objects from being properly garbage collected. @@ -230,7 +230,7 @@ Implicit binding only takes care of thrown errors and `'error'` events. <!--type=misc--> Sometimes, the domain in use is not the one that ought to be used for a -specific event emitter. Or, the event emitter could have been created +specific event emitter. Or, the event emitter could have been created in the context of one domain, but ought to instead be bound to some other domain. @@ -278,7 +278,7 @@ Returns a new Domain object. The Domain class encapsulates the functionality of routing errors and uncaught exceptions to the active Domain object. -Domain is a child class of [`EventEmitter`][]. To handle the errors that it +Domain is a child class of [`EventEmitter`][]. To handle the errors that it catches, listen to its `'error'` event. ### domain.members @@ -292,13 +292,13 @@ to the domain. * `emitter` {EventEmitter|Timer} emitter or timer to be added to the domain -Explicitly adds an emitter to the domain. If any event handlers called by +Explicitly adds an emitter to the domain. If any event handlers called by the emitter throw an error, or if the emitter emits an `'error'` event, it will be routed to the domain's `'error'` event, just like with implicit binding. This also works with timers that are returned from [`setInterval()`][] and -[`setTimeout()`][]. If their callback function throws, it will be caught by +[`setTimeout()`][]. If their callback function throws, it will be caught by the domain 'error' handler. If the Timer or EventEmitter was already bound to a domain, it is removed @@ -310,7 +310,7 @@ from that one, and bound to this one instead. * Returns: {Function} The bound function The returned function will be a wrapper around the supplied callback -function. When the returned function is called, any errors that are +function. When the returned function is called, any errors that are thrown will be routed to the domain's `'error'` event. #### Example @@ -365,7 +365,7 @@ single domain. * `callback` {Function} The callback function * Returns: {Function} The intercepted function -This method is almost identical to [`domain.bind(callback)`][]. However, in +This method is almost identical to [`domain.bind(callback)`][]. However, in addition to catching thrown errors, it will also intercept [`Error`][] objects sent as the first argument to the function. @@ -402,7 +402,7 @@ d.on('error', (er) => { * `emitter` {EventEmitter|Timer} emitter or timer to be removed from the domain -The opposite of [`domain.add(emitter)`][]. Removes domain handling from the +The opposite of [`domain.add(emitter)`][]. Removes domain handling from the specified emitter. ### domain.run(fn[, ...args]) |