@@ -16,19 +16,21 @@ Create [Node.js errors][1]
1616- [ Install] ( #install )
1717- [ Use] ( #use )
1818- [ API] ( #api )
19+ - [ ` createNodeError(code, Base, message) ` ] ( #createnodeerrorcode-base-message )
20+ - [ ` determineSpecificType(value) ` ] ( #determinespecifictypevalue )
1921- [ Types] ( #types )
2022 - [ Enums] ( #enums )
2123 - [ Type Defintions] ( #type-definitions )
2224- [ Contribute] ( #contribute )
2325
2426## What is this?
2527
26- This package provides an API for creating [ Node.js errors] [ 1 ] .
28+ This package provides utilities for creating [ Node.js errors] [ 1 ] .
2729
2830## When should I use this?
2931
30- This package is designed to help developers build [ ponyfills ] [ 2 ] and utilities like [ ` mlly ` ] [ 3 ] by providing a universal
31- API for creating [ Node.js errors] [ 1 ] .
32+ This package is designed to help developers build Node.js tools like [ ponyfills ] [ 2 ] , as well as more verbose utilities
33+ like [ ` mlly ` ] [ 3 ] , by providing a universal API for creating [ Node.js errors] [ 1 ] .
3234
3335### Differences between Node.js
3436
@@ -280,11 +282,39 @@ err instanceof TypeError: true
280282
281283## API
282284
283- ** TODO** : Update documentation.
285+ This package exports the following identifiers:
286+
287+ - [ ` createNodeError ` ] ( #createnodeerrorcode-base-message )
288+ - [ ` determineSpecificType ` ] ( #determinespecifictypevalue )
289+
290+ There is no default export.
291+
292+ ### ` createNodeError(code, Base, message) `
293+
294+ Creates a Node.js error constructor.
295+
296+ If the given error ` message ` is a function, constructor arguments are passed to ` message ` . If the ` message ` is a string,
297+ constructor arguments are passed to [ ` util.format ` ] [ 7 ] instead.
298+
299+ - ` {ErrorCode} ` ** ` code ` ** &mdash ; Node.js error code
300+ - ` {B extends ErrorConstructor} ` ** ` Base ` ** &mdash ; Error base class
301+ - ` {M extends MessageFn | string} ` ** ` message ` ** &mdash ; Error message or message function
302+ - ** Returns** : ` {NodeErrorConstructor<B, M>} ` ` NodeError ` constructor
303+
304+ > ** Source** : [ ` src/create-node-error.ts ` ] ( src/create-node-error.ts )
305+
306+ ### ` determineSpecificType(value) `
307+
308+ Determines the specific type of a value for type-mismatch errors.
309+
310+ - ` {unknown} ` ** ` value ` ** &mdash ; Value to evaluate
311+ - ** Returns** : ` {string} ` Specific type of ` value `
312+
313+ > ** Source** : [ ` src/determine-specific-type.ts ` ] ( src/determine-specific-type.ts )
284314
285315## Types
286316
287- This package is fully typed with [ TypeScript] [ 7 ] . It exports the following definitions:
317+ This package is fully typed with [ TypeScript] [ 8 ] . It exports the following definitions:
288318
289319### Enums
290320
@@ -306,4 +336,5 @@ See [`CONTRIBUTING.md`](CONTRIBUTING.md).
306336[ 4 ] : https://nodejs.org/api/errors.html#errorstacktracelimit
307337[ 5 ] : https://github.com/nodejs/node/blob/v19.3.0/lib/internal/errors.js#L484-L496
308338[ 6 ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
309- [ 7 ] : https://www.typescriptlang.org
339+ [ 7 ] : https://nodejs.org/api/util.html#utilformatformat-args
340+ [ 8 ] : https://www.typescriptlang.org
0 commit comments