1010 */
1111
1212/**
13- * @typedef {(...args : Array<any>) => string } MessageFunction
13+ * @typedef {(...parameters : Array<any>) => string } MessageFunction
1414 */
1515
1616// Manually “tree shaken” from:
@@ -187,14 +187,14 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
187187codes . ERR_INVALID_PACKAGE_TARGET = createError (
188188 'ERR_INVALID_PACKAGE_TARGET' ,
189189 /**
190- * @param {string } pkgPath
190+ * @param {string } packagePath
191191 * @param {string } key
192192 * @param {unknown } target
193193 * @param {boolean } [isImport=false]
194194 * @param {string } [base]
195195 */
196- ( pkgPath , key , target , isImport = false , base = undefined ) => {
197- const relError =
196+ ( packagePath , key , target , isImport = false , base = undefined ) => {
197+ const relatedError =
198198 typeof target === 'string' &&
199199 ! isImport &&
200200 target . length > 0 &&
@@ -203,19 +203,19 @@ codes.ERR_INVALID_PACKAGE_TARGET = createError(
203203 assert ( isImport === false )
204204 return (
205205 `Invalid "exports" main target ${ JSON . stringify ( target ) } defined ` +
206- `in the package config ${ pkgPath } package.json${
206+ `in the package config ${ packagePath } package.json${
207207 base ? ` imported from ${ base } ` : ''
208- } ${ relError ? '; targets must start with "./"' : '' } `
208+ } ${ relatedError ? '; targets must start with "./"' : '' } `
209209 )
210210 }
211211
212212 return `Invalid "${
213213 isImport ? 'imports' : 'exports'
214214 } " target ${ JSON . stringify (
215215 target
216- ) } defined for '${ key } ' in the package config ${ pkgPath } package.json${
216+ ) } defined for '${ key } ' in the package config ${ packagePath } package.json${
217217 base ? ` imported from ${ base } ` : ''
218- } ${ relError ? '; targets must start with "./"' : '' } `
218+ } ${ relatedError ? '; targets must start with "./"' : '' } `
219219 } ,
220220 Error
221221)
@@ -259,16 +259,16 @@ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
259259codes . ERR_PACKAGE_PATH_NOT_EXPORTED = createError (
260260 'ERR_PACKAGE_PATH_NOT_EXPORTED' ,
261261 /**
262- * @param {string } pkgPath
262+ * @param {string } packagePath
263263 * @param {string } subpath
264264 * @param {string } [base]
265265 */
266- ( pkgPath , subpath , base = undefined ) => {
266+ ( packagePath , subpath , base = undefined ) => {
267267 if ( subpath === '.' )
268- return `No "exports" main defined in ${ pkgPath } package.json${
268+ return `No "exports" main defined in ${ packagePath } package.json${
269269 base ? ` imported from ${ base } ` : ''
270270 } `
271- return `Package subpath '${ subpath } ' is not defined by "exports" in ${ pkgPath } package.json${
271+ return `Package subpath '${ subpath } ' is not defined by "exports" in ${ packagePath } package.json${
272272 base ? ` imported from ${ base } ` : ''
273273 } `
274274 } ,
@@ -285,11 +285,11 @@ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
285285codes . ERR_UNKNOWN_FILE_EXTENSION = createError (
286286 'ERR_UNKNOWN_FILE_EXTENSION' ,
287287 /**
288- * @param {string } ext
288+ * @param {string } extension
289289 * @param {string } path
290290 */
291- ( ext , path ) => {
292- return `Unknown file extension "${ ext } " for ${ path } `
291+ ( extension , path ) => {
292+ return `Unknown file extension "${ extension } " for ${ path } `
293293 } ,
294294 TypeError
295295)
@@ -322,15 +322,15 @@ codes.ERR_INVALID_ARG_VALUE = createError(
322322 * *only* to allow for testing.
323323 * @param {string } sym
324324 * @param {MessageFunction | string } value
325- * @param {ErrorConstructor } def
326- * @returns {new (...args : Array<any>) => Error }
325+ * @param {ErrorConstructor } constructor
326+ * @returns {new (...parameters : Array<any>) => Error }
327327 */
328- function createError ( sym , value , def ) {
328+ function createError ( sym , value , constructor ) {
329329 // Special case for SystemError that formats the error message differently
330330 // The SystemErrors only have SystemError as their base classes.
331331 messages . set ( sym , value )
332332
333- return makeNodeErrorWithCode ( def , sym )
333+ return makeNodeErrorWithCode ( constructor , sym )
334334}
335335
336336/**
@@ -342,15 +342,15 @@ function makeNodeErrorWithCode(Base, key) {
342342 // @ts -expect-error It’s a Node error.
343343 return NodeError
344344 /**
345- * @param {Array<unknown> } args
345+ * @param {Array<unknown> } parameters
346346 */
347- function NodeError ( ...args ) {
347+ function NodeError ( ...parameters ) {
348348 const limit = Error . stackTraceLimit
349349 if ( isErrorStackTraceLimitWritable ( ) ) Error . stackTraceLimit = 0
350350 const error = new Base ( )
351351 // Reset the limit and setting the name property.
352352 if ( isErrorStackTraceLimitWritable ( ) ) Error . stackTraceLimit = limit
353- const message = getMessage ( key , args , error )
353+ const message = getMessage ( key , parameters , error )
354354 Object . defineProperties ( error , {
355355 // Note: no need to implement `kIsNodeError` symbol, would be hard,
356356 // probably.
@@ -385,7 +385,6 @@ function isErrorStackTraceLimitWritable() {
385385 // Do no touch Error.stackTraceLimit as V8 would attempt to install
386386 // it again during deserialization.
387387 try {
388- // @ts -expect-error: not in types?
389388 if ( v8 . startupSnapshot . isBuildingSnapshot ( ) ) {
390389 return false
391390 }
@@ -403,16 +402,16 @@ function isErrorStackTraceLimitWritable() {
403402
404403/**
405404 * This function removes unnecessary frames from Node.js core errors.
406- * @template {(...args : unknown[]) => unknown} T
407- * @param {T } fn
405+ * @template {(...parameters : unknown[]) => unknown} T
406+ * @param {T } wrappedFunction
408407 * @returns {T }
409408 */
410- function hideStackFrames ( fn ) {
409+ function hideStackFrames ( wrappedFunction ) {
411410 // We rename the functions that will be hidden to cut off the stacktrace
412411 // at the outermost one
413- const hidden = nodeInternalPrefix + fn . name
414- Object . defineProperty ( fn , 'name' , { value : hidden } )
415- return fn
412+ const hidden = nodeInternalPrefix + wrappedFunction . name
413+ Object . defineProperty ( wrappedFunction , 'name' , { value : hidden } )
414+ return wrappedFunction
416415}
417416
418417const captureLargerStackTrace = hideStackFrames (
@@ -439,35 +438,35 @@ const captureLargerStackTrace = hideStackFrames(
439438
440439/**
441440 * @param {string } key
442- * @param {Array<unknown> } args
441+ * @param {Array<unknown> } parameters
443442 * @param {Error } self
444443 * @returns {string }
445444 */
446- function getMessage ( key , args , self ) {
445+ function getMessage ( key , parameters , self ) {
447446 const message = messages . get ( key )
448447 assert ( message !== undefined , 'expected `message` to be found' )
449448
450449 if ( typeof message === 'function' ) {
451450 assert (
452- message . length <= args . length , // Default options do not count.
453- `Code: ${ key } ; The provided arguments length (${ args . length } ) does not ` +
451+ message . length <= parameters . length , // Default options do not count.
452+ `Code: ${ key } ; The provided arguments length (${ parameters . length } ) does not ` +
454453 `match the required ones (${ message . length } ).`
455454 )
456- return Reflect . apply ( message , self , args )
455+ return Reflect . apply ( message , self , parameters )
457456 }
458457
459458 const regex = / % [ d f i j o O s ] / g
460459 let expectedLength = 0
461460 while ( regex . exec ( message ) !== null ) expectedLength ++
462461 assert (
463- expectedLength === args . length ,
464- `Code: ${ key } ; The provided arguments length (${ args . length } ) does not ` +
462+ expectedLength === parameters . length ,
463+ `Code: ${ key } ; The provided arguments length (${ parameters . length } ) does not ` +
465464 `match the required ones (${ expectedLength } ).`
466465 )
467- if ( args . length === 0 ) return message
466+ if ( parameters . length === 0 ) return message
468467
469- args . unshift ( message )
470- return Reflect . apply ( format , null , args )
468+ parameters . unshift ( message )
469+ return Reflect . apply ( format , null , parameters )
471470}
472471
473472/**
0 commit comments