Skip to content

Commit bb8d48a

Browse files
committed
build(deps): bump @flex-development/tutils from 6.0.0-alpha.10 to 6.0.0-alpha.12
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 4fd9226 commit bb8d48a

17 files changed

+117
-80
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ constructor arguments are passed to [`util.format`][15] instead.
583583

584584
- `{ErrorCode}` **`code`** &mdash; Node.js error code
585585
- `{B extends ErrorConstructor}` **`Base`** &mdash; Error base class
586-
- `{M extends any[] | MessageFn | string}` **`message`** &mdash; Error message or message function
586+
- `{M extends MessageFn | unknown[] | string}` **`message`** &mdash; Error message or message function
587587
- **Returns**: `{NodeErrorConstructor<B, M>}` `NodeError` constructor
588588

589589
> **Source**: [`src/create-node-error.ts`](src/create-node-error.ts)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"typecheck:watch": "vitest typecheck"
7373
},
7474
"dependencies": {
75-
"@flex-development/tutils": "6.0.0-alpha.10",
75+
"@flex-development/tutils": "6.0.0-alpha.12",
7676
"node-inspect-extracted": "2.0.2"
7777
},
7878
"devDependencies": {
@@ -171,7 +171,7 @@
171171
},
172172
"resolutions": {
173173
"@ardatan/sync-fetch": "larsgw/sync-fetch#head=worker_threads",
174-
"@flex-development/tutils": "6.0.0-alpha.10"
174+
"@flex-development/tutils": "6.0.0-alpha.12"
175175
},
176176
"engines": {
177177
"node": ">=16.20.0",

src/internal/format-list.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @see https://github.com/nodejs/node/blob/0f69ec4dd74d446765639274728466baf5f13cdd/lib/internal/errors.js#L905-L908
55
*/
66

7+
import { join } from '@flex-development/tutils'
8+
79
/**
810
* Creates a list string in the form `'A and B'` or `'A, B, ..., and Z`.
911
*
@@ -23,8 +25,8 @@
2325
*/
2426
function formatList(arr: string[], transition: string = 'and'): string {
2527
return arr.length < 3
26-
? arr.join(` ${transition} `)
27-
: `${arr.slice(0, -1).join(', ')}, ${transition} ${arr[arr.length - 1]}`
28+
? join(arr, ` ${transition} `)
29+
: `${join(arr.slice(0, -1), ', ')}, ${transition} ${arr[arr.length - 1]}`
2830
}
2931

3032
export default formatList

src/internal/prepare-stack-trace.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import type { NodeError } from '#src/types'
7+
import { regexp } from '@flex-development/tutils'
78

89
/**
910
* Adds a stack trace to the given `error`.
@@ -23,19 +24,7 @@ function prepareStackTrace<T extends Error = Error>(
2324

2425
// make sure stack trace is formatted properly
2526
error.stack = error.stack!.replace(
26-
new RegExp(
27-
`^${error.name}: ${error.message
28-
/*
29-
* Escape characters with special meaning, either inside or outside
30-
* character sets.
31-
*
32-
* A simple backslash escape is used when it’s always valid; a `\xnn`
33-
* escape is used when the simpler form would be disallowed by stricter
34-
* unicode patterns.
35-
*/
36-
.replace(/[$()*+.?[\\\]^{|}]/g, '\\$&')
37-
.replace(/-/g, '\\x2d')}`
38-
),
27+
new RegExp(`^${error.name}: ${regexp(error.message)}`),
3928
error.toString()
4029
)
4130

src/models/err-invalid-arg-type.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import { ErrorCode } from '#src/enums'
88
import formatList from '#src/internal/format-list'
99
import type { MessageFn, NodeError, NodeErrorConstructor } from '#src/types'
1010
import { createNodeError, determineSpecificType } from '#src/utils'
11-
import type { OneOrMany } from '@flex-development/tutils'
11+
import {
12+
DOT,
13+
includes,
14+
isArray,
15+
lowercase,
16+
type OneOrMany
17+
} from '@flex-development/tutils'
1218

1319
/**
1420
* `ERR_INVALID_ARG_TYPE` model.
@@ -47,7 +53,7 @@ const ERR_INVALID_ARG_TYPE: NodeErrorConstructor<
4753
if (typeof name !== 'string') throw new TypeError("'name' must be a string")
4854

4955
// ensure expected is an array
50-
if (!Array.isArray(expected)) expected = [expected]
56+
if (!isArray(expected)) expected = [expected]
5157

5258
/**
5359
* Primitive value names.
@@ -78,7 +84,7 @@ const ERR_INVALID_ARG_TYPE: NodeErrorConstructor<
7884
// stylize invalid argument name
7985
msg += name.endsWith(' argument')
8086
? name
81-
: `'${name}' ${name.includes('.') ? 'property' : 'argument'}`
87+
: `'${name}' ${includes(name, DOT) ? 'property' : 'argument'}`
8288

8389
// continue building error message
8490
msg += ' must be '
@@ -151,7 +157,7 @@ const ERR_INVALID_ARG_TYPE: NodeErrorConstructor<
151157
msg += `one of ${formatList(other, 'or')}`
152158
} else {
153159
/* c8 ignore next */
154-
if (other[0]!.toLowerCase() !== other[0]) msg += 'an '
160+
if (lowercase(other[0]!) !== other[0]) msg += 'an '
155161
msg += `${other[0]}`
156162
}
157163
}

src/models/err-invalid-arg-value.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { ErrorCode } from '#src/enums'
88
import type { MessageFn, NodeError, NodeErrorConstructor } from '#src/types'
99
import { createNodeError } from '#src/utils'
10+
import { DOT, includes, truncate } from '@flex-development/tutils'
1011
import { inspect } from 'node-inspect-extracted'
1112

1213
/**
@@ -58,16 +59,16 @@ const ERR_INVALID_ARG_VALUE: NodeErrorConstructor<
5859
let ret: string = 'The'
5960

6061
// trim inspected value
61-
if (inspected.length > 128) inspected = inspected.slice(0, 128) + '...'
62+
if (inspected.length > 128) inspected = truncate(inspected, 131)
6263

6364
// add stylized invalid argument or property name
64-
ret += ` ${name.includes('.') ? 'property' : 'argument'} '${name}'`
65+
ret += ` ${includes(name, DOT) ? 'property' : 'argument'} '${name}'`
6566

6667
// add reason for error
6768
if (reason) ret += ` ${reason}`
6869

6970
// add inspected value
70-
ret += `. Received ${inspected}`
71+
ret += `${DOT} Received ${inspected}`
7172

7273
return ret
7374
}

src/models/err-invalid-module-specifier.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { ErrorCode } from '#src/enums'
88
import type { MessageFn, NodeError, NodeErrorConstructor } from '#src/types'
99
import { createNodeError } from '#src/utils'
10+
import { trimEnd } from '@flex-development/tutils'
1011

1112
/**
1213
* `ERR_INVALID_MODULE_SPECIFIER` model.
@@ -45,7 +46,7 @@ const ERR_INVALID_MODULE_SPECIFIER: NodeErrorConstructor<
4546
*
4647
* @var {string} ret
4748
*/
48-
let ret: string = `Invalid module '${request}' ${reason}`.trimEnd()
49+
let ret: string = trimEnd(`Invalid module '${request}' ${reason}`)
4950

5051
// add details regarding where error occurred
5152
if (base) ret += ` imported from ${base}`

src/models/err-invalid-package-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { ErrorCode } from '#src/enums'
88
import type { MessageFn, NodeError, NodeErrorConstructor } from '#src/types'
99
import { createNodeError } from '#src/utils'
10+
import { DOT } from '@flex-development/tutils'
1011

1112
/**
1213
* `ERR_INVALID_PACKAGE_CONFIG` model.
@@ -54,7 +55,7 @@ const ERR_INVALID_PACKAGE_CONFIG: NodeErrorConstructor<
5455
if (base) ret += ` while importing ${base}`
5556

5657
// add reason package config is invalid
57-
if (reason) ret += `. ${reason}`
58+
if (reason) ret += `${DOT} ${reason}`
5859

5960
return ret
6061
}

src/models/err-invalid-package-target.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { ErrorCode } from '#src/enums'
88
import type { MessageFn, NodeError, NodeErrorConstructor } from '#src/types'
99
import { createNodeError } from '#src/utils'
10+
import { DOT, ifelse } from '@flex-development/tutils'
1011

1112
/**
1213
* `ERR_INVALID_PACKAGE_TARGET` model.
@@ -63,14 +64,14 @@ const ERR_INVALID_PACKAGE_TARGET: NodeErrorConstructor<
6364
*
6465
* @const {boolean} main
6566
*/
66-
const main: boolean = !internal && key === '.'
67+
const main: boolean = !internal && key === DOT
6768

6869
/**
6970
* Error message.
7071
*
7172
* @var {string} ret
7273
*/
73-
let ret: string = `Invalid "${internal ? 'imports' : 'exports'}"`
74+
let ret: string = `Invalid "${ifelse(internal, 'imports', 'exports')}"`
7475

7576
// include if package target is main entry point
7677
if (main) ret += ' main'
@@ -89,8 +90,8 @@ const ERR_INVALID_PACKAGE_TARGET: NodeErrorConstructor<
8990

9091
// add reason package target is invalid
9192
ret +=
92-
typeof target === 'string' && !internal && !target.startsWith('./')
93-
? '; targets must start with "./"'
93+
typeof target === 'string' && !internal && !target.startsWith(`${DOT}/`)
94+
? `; targets must start with "${DOT}/"`
9495
: ''
9596

9697
return ret

src/models/err-package-path-not-exported.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { ErrorCode } from '#src/enums'
88
import type { NodeError, NodeErrorConstructor } from '#src/types'
99
import { createNodeError } from '#src/utils'
10+
import { DOT } from '@flex-development/tutils'
1011

1112
/**
1213
* `ERR_PACKAGE_PATH_NOT_EXPORTED` model.
@@ -48,7 +49,7 @@ const ERR_PACKAGE_PATH_NOT_EXPORTED: NodeErrorConstructor<
4849
* @var {string} message
4950
*/
5051
let message: string =
51-
subpath === '.'
52+
subpath === DOT
5253
? "No 'exports' main defined in"
5354
: `Package subpath '${subpath}' is not defined by 'exports' in`
5455

0 commit comments

Comments
 (0)