-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type definitions for TypeScript (#70)
Closes #48 Signed-off-by: Jon Koops <[email protected]>
- Loading branch information
Showing
5 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ npm i [email protected] -g | |
## Usage | ||
|
||
```js | ||
import why from 'why-is-node-running' // should be your first import | ||
import whyIsNodeRunning from 'why-is-node-running' // should be your first import | ||
import net from 'node:net' | ||
|
||
function createServer () { | ||
|
@@ -32,7 +32,7 @@ createServer() | |
createServer() | ||
|
||
setTimeout(function () { | ||
why() // logs out active handles that are keeping node running | ||
whyIsNodeRunning() // logs out active handles that are keeping node running | ||
}, 100) | ||
``` | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import why from './index.js' | ||
import whyIsNodeRunning from './index.js' | ||
import siginfo from 'siginfo' | ||
|
||
siginfo(why, true) | ||
siginfo(whyIsNodeRunning, true) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* An interface that can be implemented to customize how information is logged. For example: | ||
* | ||
* ```ts | ||
* import whyIsNodeRunning, { type Logger } from 'why-is-node-running' | ||
* | ||
* const logger: Logger = { | ||
* error(message) { | ||
* console.error(message) | ||
* } | ||
* } | ||
* | ||
* whyIsNodeRunning(logger) | ||
* ``` | ||
*/ | ||
export interface Logger { | ||
error(message: string): void | ||
} | ||
|
||
/** | ||
* Logs the locations of all the active handles that prevent Node.js from exiting. | ||
* | ||
* @param logger An optional {@link Logger} to use for logging messages. If not provided, the console will be used. | ||
*/ | ||
export default function whyIsNodeRunning(logger?: Logger): void |
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