(fn, criteria = 1, field)
| 480 | } |
| 481 | |
| 482 | function _mustCallInner(fn, criteria = 1, field) { |
| 483 | if (process._exiting) |
| 484 | throw new Error('Cannot use common.mustCall*() in process exit handler'); |
| 485 | if (typeof fn === 'number') { |
| 486 | criteria = fn; |
| 487 | fn = noop; |
| 488 | } else if (fn === undefined) { |
| 489 | fn = noop; |
| 490 | } |
| 491 | |
| 492 | if (typeof criteria !== 'number') |
| 493 | throw new TypeError(`Invalid ${field} value: ${criteria}`); |
| 494 | |
| 495 | const context = { |
| 496 | [field]: criteria, |
| 497 | actual: 0, |
| 498 | stack: inspect(new Error()), |
| 499 | name: fn.name || '<anonymous>', |
| 500 | }; |
| 501 | |
| 502 | // Add the exit listener only once to avoid listener leak warnings |
| 503 | if (mustCallChecks.length === 0) process.on('exit', runCallChecks); |
| 504 | |
| 505 | mustCallChecks.push(context); |
| 506 | |
| 507 | const _return = function() { // eslint-disable-line func-style |
| 508 | context.actual++; |
| 509 | return fn.apply(this, arguments); |
| 510 | }; |
| 511 | // Function instances have own properties that may be relevant. |
| 512 | // Let's replicate those properties to the returned function. |
| 513 | // Refs: https://tc39.es/ecma262/#sec-function-instances |
| 514 | Object.defineProperties(_return, { |
| 515 | name: { |
| 516 | value: fn.name, |
| 517 | writable: false, |
| 518 | enumerable: false, |
| 519 | configurable: true, |
| 520 | }, |
| 521 | length: { |
| 522 | value: fn.length, |
| 523 | writable: false, |
| 524 | enumerable: false, |
| 525 | configurable: true, |
| 526 | }, |
| 527 | }); |
| 528 | return _return; |
| 529 | } |
| 530 | |
| 531 | function skipIfEslintMissing() { |
| 532 | if (!fs.existsSync( |
no test coverage detected
searching dependent graphs…