Skip to content

Commit

Permalink
doc/comment tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlapp committed Sep 13, 2016
1 parent 508f8c4 commit 7b0e21c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm install node-cleanup --save

## Usage

nodeCleanup() installs a function that performs cleanup activities just before the node process exits. The cleanup function runs when the process exits normally, when the user presses *ctrl*-C, and when an exception is uncaught. The caller may specify the termination messages to use.
nodeCleanup() installs a function that performs cleanup activities just before the node process exits. The cleanup function runs when the process exits normally, when the user presses *ctrl-C*, and when an exception is uncaught. The caller may specify the termination messages to use.

```js
var nodeCleanup = require('node-cleanup');
Expand All @@ -20,9 +20,9 @@ nodeCleanup(function () {
});
```

nodeCleanup() also ensures that ctrl-C is handled gracefully in contexts that already have exit handlers installed, such as Node Express. To receive just this benefit, the caller need not provide a cleanup handler.
nodeCleanup() also ensures that *ctrl-C* is handled gracefully in contexts that already have exit handlers installed, such as Node Express. To receive just this benefit, the caller need not provide a cleanup handler.

By default, `nodeCleanup()` writes `[ctrl-C]` to `stderr` when interrupted and `Uncaught exception...` to `stderr` when an uncaught exception occurs. You may override either or both of these values in a second parameter:
By default, `nodeCleanup()` writes "[ctrl-C]" to `stderr` when interrupted and "Uncaught exception..." to `stderr` when an uncaught exception occurs. You may override either or both of these values in a second parameter:

```js
var nodeCleanup = require('node-cleanup');
Expand All @@ -34,9 +34,9 @@ nodeCleanup(function () {

## Reference

`nodeCleanup(cleanupHandler, messages)`
`function nodeCleanup(cleanupHandler, messages)`

Install a cleanup handler that reliably runs when node exits. Both parameters are optional. Calling `nodeCleanup()` without a `cleanupHandler` still provides the benefit of ensuring that other installed exit handlers run on *ctrl*-C.
Install a cleanup handler that reliably runs when node exits. Both parameters are optional. Calling `nodeCleanup()` without a `cleanupHandler` still provides the benefit of ensuring that other installed exit handlers run on *ctrl-C*.

| Param | Description |
| --- | --- |
Expand Down
18 changes: 1 addition & 17 deletions node-cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,7 @@
* exits normally, when the user presses ctrl-C, and when an exception is
* uncaught. The caller may specify the termination messages to use.
*
* nodeCleanup() also ensures that ctrl-C is handled gracefully in contexts
* that already have exit handlers installed, such as Node Express. To
* receive just this benefit, the caller need not provide a cleanup handler.
*
* This code was borrowed and modified from CanyonCasa's answer to a
* stackoverflow question. I found the code necessary for all my node
* projects. See the stackoverflow answer for example usage:
* http://stackoverflow.com/a/21947851/650894
*
* @param cleanupHandler A function that performs the final cleanup of
* resources before the node process exits. The function may write to
* stderr and stdout. It takes no parameters and can't abort the exit.
* The handler is optional, defaulting to a function that does nothing.
* @param messages An optional object mapping any of the keys `ctrl_C` and
* `uncaughtException` to the message strings that output to stderr.
* Set a message to the empty string '' to prevent output to stderr
* for its case. Default messages are provided omitted messages.
* See https://github.com/jtlapp/node-cleanup for more information.
*/

module.exports = function nodeCleanup(cleanupHandler, messages) {
Expand Down

0 comments on commit 7b0e21c

Please sign in to comment.