cdk-common 2.0.417 → 2.0.418
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +2 -2
- package/lib/main.js +1 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/concat-stream/node_modules/@types/node/test.d.ts +238 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/ts4.8/test.d.ts +247 -1
- package/node_modules/@types/form-data/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/form-data/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/form-data/node_modules/@types/node/test.d.ts +238 -1
- package/node_modules/@types/form-data/node_modules/@types/node/ts4.8/test.d.ts +247 -1
- package/node_modules/concat-stream/node_modules/readable-stream/README.md +2 -2
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_readable.js +4 -4
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js +6 -8
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -1
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/destroy.js +14 -4
- package/node_modules/concat-stream/node_modules/readable-stream/package.json +1 -1
- package/package.json +2 -2
package/.jsii
CHANGED
|
@@ -9319,6 +9319,6 @@
|
|
|
9319
9319
|
"symbolId": "src/main:LambdaArmFunctionProps"
|
|
9320
9320
|
}
|
|
9321
9321
|
},
|
|
9322
|
-
"version": "2.0.
|
|
9323
|
-
"fingerprint": "
|
|
9322
|
+
"version": "2.0.418",
|
|
9323
|
+
"fingerprint": "jY13nmCqDyP0+cqjLboHc0dP28o+4LUv9C2t07jGoRI="
|
|
9324
9324
|
}
|
package/lib/main.js
CHANGED
|
@@ -41,5 +41,5 @@ class LambdaArmFunction extends constructs_1.Construct {
|
|
|
41
41
|
}
|
|
42
42
|
exports.LambdaArmFunction = LambdaArmFunction;
|
|
43
43
|
_a = JSII_RTTI_SYMBOL_1;
|
|
44
|
-
LambdaArmFunction[_a] = { fqn: "cdk-common.LambdaArmFunction", version: "2.0.
|
|
44
|
+
LambdaArmFunction[_a] = { fqn: "cdk-common.LambdaArmFunction", version: "2.0.418" };
|
|
45
45
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsbUNBQW1DO0FBQ25DLGlEQUFpRDtBQUNqRCwyQ0FBdUM7QUFLdkMsTUFBYSxpQkFBa0IsU0FBUSxzQkFBUztJQUU5QyxZQUFZLEtBQWdCLEVBQUUsRUFBVSxFQUFFLEtBQTRCO1FBQ3BFLEtBQUssQ0FBQyxLQUFLLEVBQUUsRUFBRSxDQUFDLENBQUM7UUFFakIsSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsV0FBVyxFQUFFO1lBQ2hELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxtQ0FBbUMsQ0FBQyxDQUFDO1NBQzFFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsV0FBVyxFQUFFO1lBQ3ZELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxtQ0FBbUMsQ0FBQyxDQUFDO1NBQzFFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsVUFBVSxFQUFFO1lBQ3RELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxpQ0FBaUMsQ0FBQyxDQUFDO1NBQ3hFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsVUFBVSxFQUFFO1lBQ3RELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxpQ0FBaUMsQ0FBQyxDQUFDO1NBQ3hFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsZUFBZSxFQUFFO1lBQzNELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxvQ0FBb0MsQ0FBQyxDQUFDO1NBQzNFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFO1lBQ25ELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyw4QkFBOEIsQ0FBQyxDQUFDO1NBQ3JFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsZUFBZSxFQUFFO1lBQzNELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQyxzQ0FBc0MsQ0FBQyxDQUFDO1NBQzdFO2FBQU0sSUFBSSxLQUFLLENBQUMsT0FBTyxLQUFLLE1BQU0sQ0FBQyxPQUFPLENBQUMsUUFBUSxFQUFFO1lBQ3BELEdBQUcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVUsQ0FBQywrQkFBK0IsQ0FBQyxDQUFDO1NBQ3RFO2FBQU07WUFDTCxNQUFNLElBQUksS0FBSyxDQUFDLG1CQUFtQixLQUFLLENBQUMsT0FBTyx1R0FBdUcsQ0FBQyxDQUFDO1NBQzFKO1FBRUQsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLE1BQU0sQ0FBQyxRQUFRLENBQUMsSUFBSSxFQUFFLGdCQUFnQixFQUFFLEVBQUUsWUFBWSxFQUFFLE1BQU0sQ0FBQyxZQUFZLENBQUMsTUFBTSxFQUFFLEdBQUcsS0FBSyxFQUFFLENBQUMsQ0FBQztJQUM1SCxDQUFDOztBQTFCSCw4Q0EyQkMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgKiBhcyBjZGsgZnJvbSAnYXdzLWNkay1saWInO1xuaW1wb3J0ICogYXMgbGFtYmRhIGZyb20gJ2F3cy1jZGstbGliL2F3cy1sYW1iZGEnO1xuaW1wb3J0IHsgQ29uc3RydWN0IH0gZnJvbSAnY29uc3RydWN0cyc7XG5leHBvcnQgaW50ZXJmYWNlIExhbWJkYUFybUZ1bmN0aW9uUHJvcHMgZXh0ZW5kcyBsYW1iZGEuRnVuY3Rpb25Qcm9wcyB7XG5cbn1cblxuZXhwb3J0IGNsYXNzIExhbWJkYUFybUZ1bmN0aW9uIGV4dGVuZHMgQ29uc3RydWN0IHtcbiAgcHVibGljIHJlYWRvbmx5IGxhbWJkYUZ1bmN0aW9uOiBsYW1iZGEuRnVuY3Rpb247XG4gIGNvbnN0cnVjdG9yKHNjb3BlOiBDb25zdHJ1Y3QsIGlkOiBzdHJpbmcsIHByb3BzOkxhbWJkYUFybUZ1bmN0aW9uUHJvcHMpIHtcbiAgICBzdXBlcihzY29wZSwgaWQpO1xuXG4gICAgaWYgKHByb3BzLnJ1bnRpbWUgPT09IGxhbWJkYS5SdW50aW1lLk5PREVKU18xMl9YKSB7XG4gICAgICBjZGsuQW5ub3RhdGlvbnMub2YodGhpcykuYWRkV2FybmluZygnWW91IGFyZSB1c2luZyBOb2RlLmpzIDEyLnggYXQgQVJNJyk7XG4gICAgfSBlbHNlIGlmIChwcm9wcy5ydW50aW1lID09PSBsYW1iZGEuUnVudGltZS5OT0RFSlNfMTRfWCkge1xuICAgICAgY2RrLkFubm90YXRpb25zLm9mKHRoaXMpLmFkZFdhcm5pbmcoJ1lvdSBhcmUgdXNpbmcgTm9kZS5qcyAxNC54IGF0IEFSTScpO1xuICAgIH0gZWxzZSBpZiAocHJvcHMucnVudGltZSA9PT0gbGFtYmRhLlJ1bnRpbWUuUFlUSE9OXzNfOCkge1xuICAgICAgY2RrLkFubm90YXRpb25zLm9mKHRoaXMpLmFkZFdhcm5pbmcoJ1lvdSBhcmUgdXNpbmcgUHl0aG9uIDMuOCBhdCBBUk0nKTtcbiAgICB9IGVsc2UgaWYgKHByb3BzLnJ1bnRpbWUgPT09IGxhbWJkYS5SdW50aW1lLlBZVEhPTl8zXzkpIHtcbiAgICAgIGNkay5Bbm5vdGF0aW9ucy5vZih0aGlzKS5hZGRXYXJuaW5nKCdZb3UgYXJlIHVzaW5nIFB5dGhvbiAzLjkgYXQgQVJNJyk7XG4gICAgfSBlbHNlIGlmIChwcm9wcy5ydW50aW1lID09PSBsYW1iZGEuUnVudGltZS5KQVZBXzhfQ09SUkVUVE8pIHtcbiAgICAgIGNkay5Bbm5vdGF0aW9ucy5vZih0aGlzKS5hZGRXYXJuaW5nKCdZb3UgYXJlIHVzaW5nIEphdmEgOCBvbiBhbDIgYXQgQVJNJyk7XG4gICAgfSBlbHNlIGlmIChwcm9wcy5ydW50aW1lID09PSBsYW1iZGEuUnVudGltZS5KQVZBXzExKSB7XG4gICAgICBjZGsuQW5ub3RhdGlvbnMub2YodGhpcykuYWRkV2FybmluZygnWW91IGFyZSB1c2luZyBKYXZhIDExIGF0IEFSTScpO1xuICAgIH0gZWxzZSBpZiAocHJvcHMucnVudGltZSA9PT0gbGFtYmRhLlJ1bnRpbWUuRE9UTkVUX0NPUkVfM18xKSB7XG4gICAgICBjZGsuQW5ub3RhdGlvbnMub2YodGhpcykuYWRkV2FybmluZygnWW91IGFyZSB1c2luZyBET1RORVQgQ09SRSAzLjEgYXQgQVJNJyk7XG4gICAgfSBlbHNlIGlmIChwcm9wcy5ydW50aW1lID09PSBsYW1iZGEuUnVudGltZS5SVUJZXzJfNykge1xuICAgICAgY2RrLkFubm90YXRpb25zLm9mKHRoaXMpLmFkZFdhcm5pbmcoJ1lvdSBhcmUgdXNpbmcgUlVCWSAyLjcgYXQgQVJNJyk7XG4gICAgfSBlbHNlIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihgSW52YWxpZCBSdW50aW1lICR7cHJvcHMucnVudGltZX0gYXQgQVJNLCBTZWUgaHR0cHM6Ly9kb2NzLmF3cy5hbWF6b24uY29tL2xhbWJkYS9sYXRlc3QvZGcvZm91bmRhdGlvbi1hcmNoLmh0bWw/aWNtcGlkPWRvY3NfbGFtYmRhX3Jzc2ApO1xuICAgIH1cblxuICAgIHRoaXMubGFtYmRhRnVuY3Rpb24gPSBuZXcgbGFtYmRhLkZ1bmN0aW9uKHRoaXMsICdMYW1iZGFGdW5jdGlvbicsIHsgYXJjaGl0ZWN0dXJlOiBsYW1iZGEuQXJjaGl0ZWN0dXJlLkFSTV82NCwgLi4ucHJvcHMgfSk7XG4gIH1cbn0iXX0=
|
|
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Thu, 23 Feb 2023 11:02:31 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.14.
|
|
3
|
+
"version": "18.14.1",
|
|
4
4
|
"description": "TypeScript definitions for Node.js",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -232,6 +232,6 @@
|
|
|
232
232
|
},
|
|
233
233
|
"scripts": {},
|
|
234
234
|
"dependencies": {},
|
|
235
|
-
"typesPublisherContentHash": "
|
|
235
|
+
"typesPublisherContentHash": "4b700d8e69578ec73360139a785868405bb684e4fe62cd395573dccfde90213e",
|
|
236
236
|
"typeScriptVersion": "4.2"
|
|
237
237
|
}
|
|
@@ -342,6 +342,10 @@ declare module 'node:test' {
|
|
|
342
342
|
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
|
343
343
|
*/
|
|
344
344
|
test: typeof test;
|
|
345
|
+
/**
|
|
346
|
+
* Each test provides its own MockTracker instance.
|
|
347
|
+
*/
|
|
348
|
+
readonly mock: MockTracker;
|
|
345
349
|
}
|
|
346
350
|
|
|
347
351
|
interface TestOptions {
|
|
@@ -451,5 +455,238 @@ declare module 'node:test' {
|
|
|
451
455
|
timeout?: number | undefined;
|
|
452
456
|
}
|
|
453
457
|
|
|
454
|
-
|
|
458
|
+
interface MockFunctionOptions {
|
|
459
|
+
/**
|
|
460
|
+
* The number of times that the mock will use the behavior of `implementation`.
|
|
461
|
+
* Once the mock function has been called `times` times,
|
|
462
|
+
* it will automatically restore the behavior of `original`.
|
|
463
|
+
* This value must be an integer greater than zero.
|
|
464
|
+
* @default Infinity
|
|
465
|
+
*/
|
|
466
|
+
times?: number | undefined;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
interface MockMethodOptions extends MockFunctionOptions {
|
|
470
|
+
/**
|
|
471
|
+
* If `true`, `object[methodName]` is treated as a getter.
|
|
472
|
+
* This option cannot be used with the `setter` option.
|
|
473
|
+
*/
|
|
474
|
+
getter?: boolean | undefined;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* If `true`, `object[methodName]` is treated as a setter.
|
|
478
|
+
* This option cannot be used with the `getter` option.
|
|
479
|
+
*/
|
|
480
|
+
setter?: boolean | undefined;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
type Mock<F extends Function> = F & {
|
|
484
|
+
mock: MockFunctionContext<F>;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type NoOpFunction = (...args: any[]) => undefined;
|
|
488
|
+
|
|
489
|
+
type FunctionPropertyNames<T> = {
|
|
490
|
+
[K in keyof T]: T[K] extends Function ? K : never;
|
|
491
|
+
}[keyof T];
|
|
492
|
+
|
|
493
|
+
interface MockTracker {
|
|
494
|
+
/**
|
|
495
|
+
* This function is used to create a mock function.
|
|
496
|
+
* @param original An optional function to create a mock on.
|
|
497
|
+
* @param implementation An optional function used as the mock implementation for `original`.
|
|
498
|
+
* This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`.
|
|
499
|
+
* @param options Optional configuration options for the mock function.
|
|
500
|
+
*/
|
|
501
|
+
fn<F extends Function = NoOpFunction>(original?: F, options?: MockFunctionOptions): Mock<F>;
|
|
502
|
+
fn<F extends Function = NoOpFunction, Implementation extends Function = F>(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock<F | Implementation>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* This function is used to create a mock on an existing object method.
|
|
506
|
+
* @param object The object whose method is being mocked.
|
|
507
|
+
* @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
|
|
508
|
+
* @param implementation An optional function used as the mock implementation for `object[methodName]`.
|
|
509
|
+
* @param options Optional configuration options for the mock method.
|
|
510
|
+
*/
|
|
511
|
+
method<
|
|
512
|
+
MockedObject extends object,
|
|
513
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
514
|
+
>(
|
|
515
|
+
object: MockedObject,
|
|
516
|
+
methodName: MethodName,
|
|
517
|
+
options?: MockFunctionOptions,
|
|
518
|
+
): MockedObject[MethodName] extends Function
|
|
519
|
+
? Mock<MockedObject[MethodName]>
|
|
520
|
+
: never;
|
|
521
|
+
method<
|
|
522
|
+
MockedObject extends object,
|
|
523
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
524
|
+
Implementation extends Function,
|
|
525
|
+
>(
|
|
526
|
+
object: MockedObject,
|
|
527
|
+
methodName: MethodName,
|
|
528
|
+
implementation: Implementation,
|
|
529
|
+
options?: MockFunctionOptions,
|
|
530
|
+
): MockedObject[MethodName] extends Function
|
|
531
|
+
? Mock<MockedObject[MethodName] | Implementation>
|
|
532
|
+
: never;
|
|
533
|
+
method<MockedObject extends object>(
|
|
534
|
+
object: MockedObject,
|
|
535
|
+
methodName: keyof MockedObject,
|
|
536
|
+
options: MockMethodOptions,
|
|
537
|
+
): Mock<Function>;
|
|
538
|
+
method<MockedObject extends object>(
|
|
539
|
+
object: MockedObject,
|
|
540
|
+
methodName: keyof MockedObject,
|
|
541
|
+
implementation: Function,
|
|
542
|
+
options: MockMethodOptions,
|
|
543
|
+
): Mock<Function>;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.getter` set to `true`.
|
|
547
|
+
*/
|
|
548
|
+
getter<
|
|
549
|
+
MockedObject extends object,
|
|
550
|
+
MethodName extends keyof MockedObject,
|
|
551
|
+
>(
|
|
552
|
+
object: MockedObject,
|
|
553
|
+
methodName: MethodName,
|
|
554
|
+
options?: MockFunctionOptions,
|
|
555
|
+
): Mock<() => MockedObject[MethodName]>;
|
|
556
|
+
getter<
|
|
557
|
+
MockedObject extends object,
|
|
558
|
+
MethodName extends keyof MockedObject,
|
|
559
|
+
Implementation extends Function,
|
|
560
|
+
>(
|
|
561
|
+
object: MockedObject,
|
|
562
|
+
methodName: MethodName,
|
|
563
|
+
implementation?: Implementation,
|
|
564
|
+
options?: MockFunctionOptions,
|
|
565
|
+
): Mock<(() => MockedObject[MethodName]) | Implementation>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.setter` set to `true`.
|
|
569
|
+
*/
|
|
570
|
+
setter<
|
|
571
|
+
MockedObject extends object,
|
|
572
|
+
MethodName extends keyof MockedObject,
|
|
573
|
+
>(
|
|
574
|
+
object: MockedObject,
|
|
575
|
+
methodName: MethodName,
|
|
576
|
+
options?: MockFunctionOptions,
|
|
577
|
+
): Mock<(value: MockedObject[MethodName]) => void>;
|
|
578
|
+
setter<
|
|
579
|
+
MockedObject extends object,
|
|
580
|
+
MethodName extends keyof MockedObject,
|
|
581
|
+
Implementation extends Function,
|
|
582
|
+
>(
|
|
583
|
+
object: MockedObject,
|
|
584
|
+
methodName: MethodName,
|
|
585
|
+
implementation?: Implementation,
|
|
586
|
+
options?: MockFunctionOptions,
|
|
587
|
+
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`
|
|
591
|
+
* and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used,
|
|
592
|
+
* but the `MockTracker` instance can no longer be used to reset their behavior or otherwise interact with them.
|
|
593
|
+
*
|
|
594
|
+
* After each test completes, this function is called on the test context's `MockTracker`.
|
|
595
|
+
* If the global `MockTracker` is used extensively, calling this function manually is recommended.
|
|
596
|
+
*/
|
|
597
|
+
reset(): void;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`.
|
|
601
|
+
* Unlike `mock.reset()`, `mock.restoreAll()` does not disassociate the mocks from the `MockTracker` instance.
|
|
602
|
+
*/
|
|
603
|
+
restoreAll(): void;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const mock: MockTracker;
|
|
607
|
+
|
|
608
|
+
interface MockFunctionCall<
|
|
609
|
+
F extends Function,
|
|
610
|
+
ReturnType = F extends (...args: any) => infer T
|
|
611
|
+
? T
|
|
612
|
+
: F extends abstract new (...args: any) => infer T
|
|
613
|
+
? T
|
|
614
|
+
: unknown,
|
|
615
|
+
Args = F extends (...args: infer Y) => any
|
|
616
|
+
? Y
|
|
617
|
+
: F extends abstract new (...args: infer Y) => any
|
|
618
|
+
? Y
|
|
619
|
+
: unknown[],
|
|
620
|
+
> {
|
|
621
|
+
/**
|
|
622
|
+
* An array of the arguments passed to the mock function.
|
|
623
|
+
*/
|
|
624
|
+
arguments: Args;
|
|
625
|
+
/**
|
|
626
|
+
* If the mocked function threw then this property contains the thrown value.
|
|
627
|
+
*/
|
|
628
|
+
error: unknown | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* The value returned by the mocked function.
|
|
631
|
+
*
|
|
632
|
+
* If the mocked function threw, it will be `undefined`.
|
|
633
|
+
*/
|
|
634
|
+
result: ReturnType | undefined;
|
|
635
|
+
/**
|
|
636
|
+
* An `Error` object whose stack can be used to determine the callsite of the mocked function invocation.
|
|
637
|
+
*/
|
|
638
|
+
stack: Error;
|
|
639
|
+
/**
|
|
640
|
+
* If the mocked function is a constructor, this field contains the class being constructed.
|
|
641
|
+
* Otherwise this will be `undefined`.
|
|
642
|
+
*/
|
|
643
|
+
target: F extends abstract new (...args: any) => any ? F : undefined;
|
|
644
|
+
/**
|
|
645
|
+
* The mocked function's `this` value.
|
|
646
|
+
*/
|
|
647
|
+
this: unknown;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
interface MockFunctionContext<F extends Function> {
|
|
651
|
+
/**
|
|
652
|
+
* A getter that returns a copy of the internal array used to track calls to the mock.
|
|
653
|
+
*/
|
|
654
|
+
readonly calls: Array<MockFunctionCall<F>>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* This function returns the number of times that this mock has been invoked.
|
|
658
|
+
* This function is more efficient than checking `ctx.calls.length`
|
|
659
|
+
* because `ctx.calls` is a getter that creates a copy of the internal call tracking array.
|
|
660
|
+
*/
|
|
661
|
+
callCount(): number;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* This function is used to change the behavior of an existing mock.
|
|
665
|
+
* @param implementation The function to be used as the mock's new implementation.
|
|
666
|
+
*/
|
|
667
|
+
mockImplementation(implementation: Function): void;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* This function is used to change the behavior of an existing mock for a single invocation.
|
|
671
|
+
* Once invocation `onCall` has occurred, the mock will revert to whatever behavior
|
|
672
|
+
* it would have used had `mockImplementationOnce()` not been called.
|
|
673
|
+
* @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
|
|
674
|
+
* @param onCall The invocation number that will use `implementation`.
|
|
675
|
+
* If the specified invocation has already occurred then an exception is thrown.
|
|
676
|
+
*/
|
|
677
|
+
mockImplementationOnce(implementation: Function, onCall?: number): void;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Resets the call history of the mock function.
|
|
681
|
+
*/
|
|
682
|
+
resetCalls(): void;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Resets the implementation of the mock function to its original behavior.
|
|
686
|
+
* The mock can still be used after calling this function.
|
|
687
|
+
*/
|
|
688
|
+
restore(): void;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock };
|
|
455
692
|
}
|
|
@@ -264,6 +264,15 @@ declare module 'node:test' {
|
|
|
264
264
|
*/
|
|
265
265
|
beforeEach: typeof beforeEach;
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* This function is used to create a hook that runs after the current test finishes.
|
|
269
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
270
|
+
* the second argument. Default: A no-op function.
|
|
271
|
+
* @param options Configuration options for the hook.
|
|
272
|
+
* @since v18.13.0
|
|
273
|
+
*/
|
|
274
|
+
after: typeof after;
|
|
275
|
+
|
|
267
276
|
/**
|
|
268
277
|
* This function is used to create a hook running after each subtest of the current test.
|
|
269
278
|
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
@@ -333,6 +342,10 @@ declare module 'node:test' {
|
|
|
333
342
|
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
|
334
343
|
*/
|
|
335
344
|
test: typeof test;
|
|
345
|
+
/**
|
|
346
|
+
* Each test provides its own MockTracker instance.
|
|
347
|
+
*/
|
|
348
|
+
readonly mock: MockTracker;
|
|
336
349
|
}
|
|
337
350
|
|
|
338
351
|
interface TestOptions {
|
|
@@ -442,5 +455,238 @@ declare module 'node:test' {
|
|
|
442
455
|
timeout?: number | undefined;
|
|
443
456
|
}
|
|
444
457
|
|
|
445
|
-
|
|
458
|
+
interface MockFunctionOptions {
|
|
459
|
+
/**
|
|
460
|
+
* The number of times that the mock will use the behavior of `implementation`.
|
|
461
|
+
* Once the mock function has been called `times` times,
|
|
462
|
+
* it will automatically restore the behavior of `original`.
|
|
463
|
+
* This value must be an integer greater than zero.
|
|
464
|
+
* @default Infinity
|
|
465
|
+
*/
|
|
466
|
+
times?: number | undefined;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
interface MockMethodOptions extends MockFunctionOptions {
|
|
470
|
+
/**
|
|
471
|
+
* If `true`, `object[methodName]` is treated as a getter.
|
|
472
|
+
* This option cannot be used with the `setter` option.
|
|
473
|
+
*/
|
|
474
|
+
getter?: boolean | undefined;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* If `true`, `object[methodName]` is treated as a setter.
|
|
478
|
+
* This option cannot be used with the `getter` option.
|
|
479
|
+
*/
|
|
480
|
+
setter?: boolean | undefined;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
type Mock<F extends Function> = F & {
|
|
484
|
+
mock: MockFunctionContext<F>;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type NoOpFunction = (...args: any[]) => undefined;
|
|
488
|
+
|
|
489
|
+
type FunctionPropertyNames<T> = {
|
|
490
|
+
[K in keyof T]: T[K] extends Function ? K : never;
|
|
491
|
+
}[keyof T];
|
|
492
|
+
|
|
493
|
+
interface MockTracker {
|
|
494
|
+
/**
|
|
495
|
+
* This function is used to create a mock function.
|
|
496
|
+
* @param original An optional function to create a mock on.
|
|
497
|
+
* @param implementation An optional function used as the mock implementation for `original`.
|
|
498
|
+
* This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`.
|
|
499
|
+
* @param options Optional configuration options for the mock function.
|
|
500
|
+
*/
|
|
501
|
+
fn<F extends Function = NoOpFunction>(original?: F, options?: MockFunctionOptions): Mock<F>;
|
|
502
|
+
fn<F extends Function = NoOpFunction, Implementation extends Function = F>(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock<F | Implementation>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* This function is used to create a mock on an existing object method.
|
|
506
|
+
* @param object The object whose method is being mocked.
|
|
507
|
+
* @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
|
|
508
|
+
* @param implementation An optional function used as the mock implementation for `object[methodName]`.
|
|
509
|
+
* @param options Optional configuration options for the mock method.
|
|
510
|
+
*/
|
|
511
|
+
method<
|
|
512
|
+
MockedObject extends object,
|
|
513
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
514
|
+
>(
|
|
515
|
+
object: MockedObject,
|
|
516
|
+
methodName: MethodName,
|
|
517
|
+
options?: MockFunctionOptions,
|
|
518
|
+
): MockedObject[MethodName] extends Function
|
|
519
|
+
? Mock<MockedObject[MethodName]>
|
|
520
|
+
: never;
|
|
521
|
+
method<
|
|
522
|
+
MockedObject extends object,
|
|
523
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
524
|
+
Implementation extends Function,
|
|
525
|
+
>(
|
|
526
|
+
object: MockedObject,
|
|
527
|
+
methodName: MethodName,
|
|
528
|
+
implementation: Implementation,
|
|
529
|
+
options?: MockFunctionOptions,
|
|
530
|
+
): MockedObject[MethodName] extends Function
|
|
531
|
+
? Mock<MockedObject[MethodName] | Implementation>
|
|
532
|
+
: never;
|
|
533
|
+
method<MockedObject extends object>(
|
|
534
|
+
object: MockedObject,
|
|
535
|
+
methodName: keyof MockedObject,
|
|
536
|
+
options: MockMethodOptions,
|
|
537
|
+
): Mock<Function>;
|
|
538
|
+
method<MockedObject extends object>(
|
|
539
|
+
object: MockedObject,
|
|
540
|
+
methodName: keyof MockedObject,
|
|
541
|
+
implementation: Function,
|
|
542
|
+
options: MockMethodOptions,
|
|
543
|
+
): Mock<Function>;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.getter` set to `true`.
|
|
547
|
+
*/
|
|
548
|
+
getter<
|
|
549
|
+
MockedObject extends object,
|
|
550
|
+
MethodName extends keyof MockedObject,
|
|
551
|
+
>(
|
|
552
|
+
object: MockedObject,
|
|
553
|
+
methodName: MethodName,
|
|
554
|
+
options?: MockFunctionOptions,
|
|
555
|
+
): Mock<() => MockedObject[MethodName]>;
|
|
556
|
+
getter<
|
|
557
|
+
MockedObject extends object,
|
|
558
|
+
MethodName extends keyof MockedObject,
|
|
559
|
+
Implementation extends Function,
|
|
560
|
+
>(
|
|
561
|
+
object: MockedObject,
|
|
562
|
+
methodName: MethodName,
|
|
563
|
+
implementation?: Implementation,
|
|
564
|
+
options?: MockFunctionOptions,
|
|
565
|
+
): Mock<(() => MockedObject[MethodName]) | Implementation>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.setter` set to `true`.
|
|
569
|
+
*/
|
|
570
|
+
setter<
|
|
571
|
+
MockedObject extends object,
|
|
572
|
+
MethodName extends keyof MockedObject,
|
|
573
|
+
>(
|
|
574
|
+
object: MockedObject,
|
|
575
|
+
methodName: MethodName,
|
|
576
|
+
options?: MockFunctionOptions,
|
|
577
|
+
): Mock<(value: MockedObject[MethodName]) => void>;
|
|
578
|
+
setter<
|
|
579
|
+
MockedObject extends object,
|
|
580
|
+
MethodName extends keyof MockedObject,
|
|
581
|
+
Implementation extends Function,
|
|
582
|
+
>(
|
|
583
|
+
object: MockedObject,
|
|
584
|
+
methodName: MethodName,
|
|
585
|
+
implementation?: Implementation,
|
|
586
|
+
options?: MockFunctionOptions,
|
|
587
|
+
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`
|
|
591
|
+
* and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used,
|
|
592
|
+
* but the `MockTracker` instance can no longer be used to reset their behavior or otherwise interact with them.
|
|
593
|
+
*
|
|
594
|
+
* After each test completes, this function is called on the test context's `MockTracker`.
|
|
595
|
+
* If the global `MockTracker` is used extensively, calling this function manually is recommended.
|
|
596
|
+
*/
|
|
597
|
+
reset(): void;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`.
|
|
601
|
+
* Unlike `mock.reset()`, `mock.restoreAll()` does not disassociate the mocks from the `MockTracker` instance.
|
|
602
|
+
*/
|
|
603
|
+
restoreAll(): void;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const mock: MockTracker;
|
|
607
|
+
|
|
608
|
+
interface MockFunctionCall<
|
|
609
|
+
F extends Function,
|
|
610
|
+
ReturnType = F extends (...args: any) => infer T
|
|
611
|
+
? T
|
|
612
|
+
: F extends abstract new (...args: any) => infer T
|
|
613
|
+
? T
|
|
614
|
+
: unknown,
|
|
615
|
+
Args = F extends (...args: infer Y) => any
|
|
616
|
+
? Y
|
|
617
|
+
: F extends abstract new (...args: infer Y) => any
|
|
618
|
+
? Y
|
|
619
|
+
: unknown[],
|
|
620
|
+
> {
|
|
621
|
+
/**
|
|
622
|
+
* An array of the arguments passed to the mock function.
|
|
623
|
+
*/
|
|
624
|
+
arguments: Args;
|
|
625
|
+
/**
|
|
626
|
+
* If the mocked function threw then this property contains the thrown value.
|
|
627
|
+
*/
|
|
628
|
+
error: unknown | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* The value returned by the mocked function.
|
|
631
|
+
*
|
|
632
|
+
* If the mocked function threw, it will be `undefined`.
|
|
633
|
+
*/
|
|
634
|
+
result: ReturnType | undefined;
|
|
635
|
+
/**
|
|
636
|
+
* An `Error` object whose stack can be used to determine the callsite of the mocked function invocation.
|
|
637
|
+
*/
|
|
638
|
+
stack: Error;
|
|
639
|
+
/**
|
|
640
|
+
* If the mocked function is a constructor, this field contains the class being constructed.
|
|
641
|
+
* Otherwise this will be `undefined`.
|
|
642
|
+
*/
|
|
643
|
+
target: F extends abstract new (...args: any) => any ? F : undefined;
|
|
644
|
+
/**
|
|
645
|
+
* The mocked function's `this` value.
|
|
646
|
+
*/
|
|
647
|
+
this: unknown;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
interface MockFunctionContext<F extends Function> {
|
|
651
|
+
/**
|
|
652
|
+
* A getter that returns a copy of the internal array used to track calls to the mock.
|
|
653
|
+
*/
|
|
654
|
+
readonly calls: Array<MockFunctionCall<F>>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* This function returns the number of times that this mock has been invoked.
|
|
658
|
+
* This function is more efficient than checking `ctx.calls.length`
|
|
659
|
+
* because `ctx.calls` is a getter that creates a copy of the internal call tracking array.
|
|
660
|
+
*/
|
|
661
|
+
callCount(): number;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* This function is used to change the behavior of an existing mock.
|
|
665
|
+
* @param implementation The function to be used as the mock's new implementation.
|
|
666
|
+
*/
|
|
667
|
+
mockImplementation(implementation: Function): void;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* This function is used to change the behavior of an existing mock for a single invocation.
|
|
671
|
+
* Once invocation `onCall` has occurred, the mock will revert to whatever behavior
|
|
672
|
+
* it would have used had `mockImplementationOnce()` not been called.
|
|
673
|
+
* @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
|
|
674
|
+
* @param onCall The invocation number that will use `implementation`.
|
|
675
|
+
* If the specified invocation has already occurred then an exception is thrown.
|
|
676
|
+
*/
|
|
677
|
+
mockImplementationOnce(implementation: Function, onCall?: number): void;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Resets the call history of the mock function.
|
|
681
|
+
*/
|
|
682
|
+
resetCalls(): void;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Resets the implementation of the mock function to its original behavior.
|
|
686
|
+
* The mock can still be used after calling this function.
|
|
687
|
+
*/
|
|
688
|
+
restore(): void;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock };
|
|
446
692
|
}
|
|
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Thu, 23 Feb 2023 11:02:31 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.14.
|
|
3
|
+
"version": "18.14.1",
|
|
4
4
|
"description": "TypeScript definitions for Node.js",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -232,6 +232,6 @@
|
|
|
232
232
|
},
|
|
233
233
|
"scripts": {},
|
|
234
234
|
"dependencies": {},
|
|
235
|
-
"typesPublisherContentHash": "
|
|
235
|
+
"typesPublisherContentHash": "4b700d8e69578ec73360139a785868405bb684e4fe62cd395573dccfde90213e",
|
|
236
236
|
"typeScriptVersion": "4.2"
|
|
237
237
|
}
|
|
@@ -342,6 +342,10 @@ declare module 'node:test' {
|
|
|
342
342
|
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
|
343
343
|
*/
|
|
344
344
|
test: typeof test;
|
|
345
|
+
/**
|
|
346
|
+
* Each test provides its own MockTracker instance.
|
|
347
|
+
*/
|
|
348
|
+
readonly mock: MockTracker;
|
|
345
349
|
}
|
|
346
350
|
|
|
347
351
|
interface TestOptions {
|
|
@@ -451,5 +455,238 @@ declare module 'node:test' {
|
|
|
451
455
|
timeout?: number | undefined;
|
|
452
456
|
}
|
|
453
457
|
|
|
454
|
-
|
|
458
|
+
interface MockFunctionOptions {
|
|
459
|
+
/**
|
|
460
|
+
* The number of times that the mock will use the behavior of `implementation`.
|
|
461
|
+
* Once the mock function has been called `times` times,
|
|
462
|
+
* it will automatically restore the behavior of `original`.
|
|
463
|
+
* This value must be an integer greater than zero.
|
|
464
|
+
* @default Infinity
|
|
465
|
+
*/
|
|
466
|
+
times?: number | undefined;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
interface MockMethodOptions extends MockFunctionOptions {
|
|
470
|
+
/**
|
|
471
|
+
* If `true`, `object[methodName]` is treated as a getter.
|
|
472
|
+
* This option cannot be used with the `setter` option.
|
|
473
|
+
*/
|
|
474
|
+
getter?: boolean | undefined;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* If `true`, `object[methodName]` is treated as a setter.
|
|
478
|
+
* This option cannot be used with the `getter` option.
|
|
479
|
+
*/
|
|
480
|
+
setter?: boolean | undefined;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
type Mock<F extends Function> = F & {
|
|
484
|
+
mock: MockFunctionContext<F>;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type NoOpFunction = (...args: any[]) => undefined;
|
|
488
|
+
|
|
489
|
+
type FunctionPropertyNames<T> = {
|
|
490
|
+
[K in keyof T]: T[K] extends Function ? K : never;
|
|
491
|
+
}[keyof T];
|
|
492
|
+
|
|
493
|
+
interface MockTracker {
|
|
494
|
+
/**
|
|
495
|
+
* This function is used to create a mock function.
|
|
496
|
+
* @param original An optional function to create a mock on.
|
|
497
|
+
* @param implementation An optional function used as the mock implementation for `original`.
|
|
498
|
+
* This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`.
|
|
499
|
+
* @param options Optional configuration options for the mock function.
|
|
500
|
+
*/
|
|
501
|
+
fn<F extends Function = NoOpFunction>(original?: F, options?: MockFunctionOptions): Mock<F>;
|
|
502
|
+
fn<F extends Function = NoOpFunction, Implementation extends Function = F>(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock<F | Implementation>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* This function is used to create a mock on an existing object method.
|
|
506
|
+
* @param object The object whose method is being mocked.
|
|
507
|
+
* @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
|
|
508
|
+
* @param implementation An optional function used as the mock implementation for `object[methodName]`.
|
|
509
|
+
* @param options Optional configuration options for the mock method.
|
|
510
|
+
*/
|
|
511
|
+
method<
|
|
512
|
+
MockedObject extends object,
|
|
513
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
514
|
+
>(
|
|
515
|
+
object: MockedObject,
|
|
516
|
+
methodName: MethodName,
|
|
517
|
+
options?: MockFunctionOptions,
|
|
518
|
+
): MockedObject[MethodName] extends Function
|
|
519
|
+
? Mock<MockedObject[MethodName]>
|
|
520
|
+
: never;
|
|
521
|
+
method<
|
|
522
|
+
MockedObject extends object,
|
|
523
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
524
|
+
Implementation extends Function,
|
|
525
|
+
>(
|
|
526
|
+
object: MockedObject,
|
|
527
|
+
methodName: MethodName,
|
|
528
|
+
implementation: Implementation,
|
|
529
|
+
options?: MockFunctionOptions,
|
|
530
|
+
): MockedObject[MethodName] extends Function
|
|
531
|
+
? Mock<MockedObject[MethodName] | Implementation>
|
|
532
|
+
: never;
|
|
533
|
+
method<MockedObject extends object>(
|
|
534
|
+
object: MockedObject,
|
|
535
|
+
methodName: keyof MockedObject,
|
|
536
|
+
options: MockMethodOptions,
|
|
537
|
+
): Mock<Function>;
|
|
538
|
+
method<MockedObject extends object>(
|
|
539
|
+
object: MockedObject,
|
|
540
|
+
methodName: keyof MockedObject,
|
|
541
|
+
implementation: Function,
|
|
542
|
+
options: MockMethodOptions,
|
|
543
|
+
): Mock<Function>;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.getter` set to `true`.
|
|
547
|
+
*/
|
|
548
|
+
getter<
|
|
549
|
+
MockedObject extends object,
|
|
550
|
+
MethodName extends keyof MockedObject,
|
|
551
|
+
>(
|
|
552
|
+
object: MockedObject,
|
|
553
|
+
methodName: MethodName,
|
|
554
|
+
options?: MockFunctionOptions,
|
|
555
|
+
): Mock<() => MockedObject[MethodName]>;
|
|
556
|
+
getter<
|
|
557
|
+
MockedObject extends object,
|
|
558
|
+
MethodName extends keyof MockedObject,
|
|
559
|
+
Implementation extends Function,
|
|
560
|
+
>(
|
|
561
|
+
object: MockedObject,
|
|
562
|
+
methodName: MethodName,
|
|
563
|
+
implementation?: Implementation,
|
|
564
|
+
options?: MockFunctionOptions,
|
|
565
|
+
): Mock<(() => MockedObject[MethodName]) | Implementation>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.setter` set to `true`.
|
|
569
|
+
*/
|
|
570
|
+
setter<
|
|
571
|
+
MockedObject extends object,
|
|
572
|
+
MethodName extends keyof MockedObject,
|
|
573
|
+
>(
|
|
574
|
+
object: MockedObject,
|
|
575
|
+
methodName: MethodName,
|
|
576
|
+
options?: MockFunctionOptions,
|
|
577
|
+
): Mock<(value: MockedObject[MethodName]) => void>;
|
|
578
|
+
setter<
|
|
579
|
+
MockedObject extends object,
|
|
580
|
+
MethodName extends keyof MockedObject,
|
|
581
|
+
Implementation extends Function,
|
|
582
|
+
>(
|
|
583
|
+
object: MockedObject,
|
|
584
|
+
methodName: MethodName,
|
|
585
|
+
implementation?: Implementation,
|
|
586
|
+
options?: MockFunctionOptions,
|
|
587
|
+
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`
|
|
591
|
+
* and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used,
|
|
592
|
+
* but the `MockTracker` instance can no longer be used to reset their behavior or otherwise interact with them.
|
|
593
|
+
*
|
|
594
|
+
* After each test completes, this function is called on the test context's `MockTracker`.
|
|
595
|
+
* If the global `MockTracker` is used extensively, calling this function manually is recommended.
|
|
596
|
+
*/
|
|
597
|
+
reset(): void;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`.
|
|
601
|
+
* Unlike `mock.reset()`, `mock.restoreAll()` does not disassociate the mocks from the `MockTracker` instance.
|
|
602
|
+
*/
|
|
603
|
+
restoreAll(): void;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const mock: MockTracker;
|
|
607
|
+
|
|
608
|
+
interface MockFunctionCall<
|
|
609
|
+
F extends Function,
|
|
610
|
+
ReturnType = F extends (...args: any) => infer T
|
|
611
|
+
? T
|
|
612
|
+
: F extends abstract new (...args: any) => infer T
|
|
613
|
+
? T
|
|
614
|
+
: unknown,
|
|
615
|
+
Args = F extends (...args: infer Y) => any
|
|
616
|
+
? Y
|
|
617
|
+
: F extends abstract new (...args: infer Y) => any
|
|
618
|
+
? Y
|
|
619
|
+
: unknown[],
|
|
620
|
+
> {
|
|
621
|
+
/**
|
|
622
|
+
* An array of the arguments passed to the mock function.
|
|
623
|
+
*/
|
|
624
|
+
arguments: Args;
|
|
625
|
+
/**
|
|
626
|
+
* If the mocked function threw then this property contains the thrown value.
|
|
627
|
+
*/
|
|
628
|
+
error: unknown | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* The value returned by the mocked function.
|
|
631
|
+
*
|
|
632
|
+
* If the mocked function threw, it will be `undefined`.
|
|
633
|
+
*/
|
|
634
|
+
result: ReturnType | undefined;
|
|
635
|
+
/**
|
|
636
|
+
* An `Error` object whose stack can be used to determine the callsite of the mocked function invocation.
|
|
637
|
+
*/
|
|
638
|
+
stack: Error;
|
|
639
|
+
/**
|
|
640
|
+
* If the mocked function is a constructor, this field contains the class being constructed.
|
|
641
|
+
* Otherwise this will be `undefined`.
|
|
642
|
+
*/
|
|
643
|
+
target: F extends abstract new (...args: any) => any ? F : undefined;
|
|
644
|
+
/**
|
|
645
|
+
* The mocked function's `this` value.
|
|
646
|
+
*/
|
|
647
|
+
this: unknown;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
interface MockFunctionContext<F extends Function> {
|
|
651
|
+
/**
|
|
652
|
+
* A getter that returns a copy of the internal array used to track calls to the mock.
|
|
653
|
+
*/
|
|
654
|
+
readonly calls: Array<MockFunctionCall<F>>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* This function returns the number of times that this mock has been invoked.
|
|
658
|
+
* This function is more efficient than checking `ctx.calls.length`
|
|
659
|
+
* because `ctx.calls` is a getter that creates a copy of the internal call tracking array.
|
|
660
|
+
*/
|
|
661
|
+
callCount(): number;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* This function is used to change the behavior of an existing mock.
|
|
665
|
+
* @param implementation The function to be used as the mock's new implementation.
|
|
666
|
+
*/
|
|
667
|
+
mockImplementation(implementation: Function): void;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* This function is used to change the behavior of an existing mock for a single invocation.
|
|
671
|
+
* Once invocation `onCall` has occurred, the mock will revert to whatever behavior
|
|
672
|
+
* it would have used had `mockImplementationOnce()` not been called.
|
|
673
|
+
* @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
|
|
674
|
+
* @param onCall The invocation number that will use `implementation`.
|
|
675
|
+
* If the specified invocation has already occurred then an exception is thrown.
|
|
676
|
+
*/
|
|
677
|
+
mockImplementationOnce(implementation: Function, onCall?: number): void;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Resets the call history of the mock function.
|
|
681
|
+
*/
|
|
682
|
+
resetCalls(): void;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Resets the implementation of the mock function to its original behavior.
|
|
686
|
+
* The mock can still be used after calling this function.
|
|
687
|
+
*/
|
|
688
|
+
restore(): void;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock };
|
|
455
692
|
}
|
|
@@ -264,6 +264,15 @@ declare module 'node:test' {
|
|
|
264
264
|
*/
|
|
265
265
|
beforeEach: typeof beforeEach;
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* This function is used to create a hook that runs after the current test finishes.
|
|
269
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
270
|
+
* the second argument. Default: A no-op function.
|
|
271
|
+
* @param options Configuration options for the hook.
|
|
272
|
+
* @since v18.13.0
|
|
273
|
+
*/
|
|
274
|
+
after: typeof after;
|
|
275
|
+
|
|
267
276
|
/**
|
|
268
277
|
* This function is used to create a hook running after each subtest of the current test.
|
|
269
278
|
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
@@ -333,6 +342,10 @@ declare module 'node:test' {
|
|
|
333
342
|
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
|
334
343
|
*/
|
|
335
344
|
test: typeof test;
|
|
345
|
+
/**
|
|
346
|
+
* Each test provides its own MockTracker instance.
|
|
347
|
+
*/
|
|
348
|
+
readonly mock: MockTracker;
|
|
336
349
|
}
|
|
337
350
|
|
|
338
351
|
interface TestOptions {
|
|
@@ -442,5 +455,238 @@ declare module 'node:test' {
|
|
|
442
455
|
timeout?: number | undefined;
|
|
443
456
|
}
|
|
444
457
|
|
|
445
|
-
|
|
458
|
+
interface MockFunctionOptions {
|
|
459
|
+
/**
|
|
460
|
+
* The number of times that the mock will use the behavior of `implementation`.
|
|
461
|
+
* Once the mock function has been called `times` times,
|
|
462
|
+
* it will automatically restore the behavior of `original`.
|
|
463
|
+
* This value must be an integer greater than zero.
|
|
464
|
+
* @default Infinity
|
|
465
|
+
*/
|
|
466
|
+
times?: number | undefined;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
interface MockMethodOptions extends MockFunctionOptions {
|
|
470
|
+
/**
|
|
471
|
+
* If `true`, `object[methodName]` is treated as a getter.
|
|
472
|
+
* This option cannot be used with the `setter` option.
|
|
473
|
+
*/
|
|
474
|
+
getter?: boolean | undefined;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* If `true`, `object[methodName]` is treated as a setter.
|
|
478
|
+
* This option cannot be used with the `getter` option.
|
|
479
|
+
*/
|
|
480
|
+
setter?: boolean | undefined;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
type Mock<F extends Function> = F & {
|
|
484
|
+
mock: MockFunctionContext<F>;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type NoOpFunction = (...args: any[]) => undefined;
|
|
488
|
+
|
|
489
|
+
type FunctionPropertyNames<T> = {
|
|
490
|
+
[K in keyof T]: T[K] extends Function ? K : never;
|
|
491
|
+
}[keyof T];
|
|
492
|
+
|
|
493
|
+
interface MockTracker {
|
|
494
|
+
/**
|
|
495
|
+
* This function is used to create a mock function.
|
|
496
|
+
* @param original An optional function to create a mock on.
|
|
497
|
+
* @param implementation An optional function used as the mock implementation for `original`.
|
|
498
|
+
* This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`.
|
|
499
|
+
* @param options Optional configuration options for the mock function.
|
|
500
|
+
*/
|
|
501
|
+
fn<F extends Function = NoOpFunction>(original?: F, options?: MockFunctionOptions): Mock<F>;
|
|
502
|
+
fn<F extends Function = NoOpFunction, Implementation extends Function = F>(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock<F | Implementation>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* This function is used to create a mock on an existing object method.
|
|
506
|
+
* @param object The object whose method is being mocked.
|
|
507
|
+
* @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
|
|
508
|
+
* @param implementation An optional function used as the mock implementation for `object[methodName]`.
|
|
509
|
+
* @param options Optional configuration options for the mock method.
|
|
510
|
+
*/
|
|
511
|
+
method<
|
|
512
|
+
MockedObject extends object,
|
|
513
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
514
|
+
>(
|
|
515
|
+
object: MockedObject,
|
|
516
|
+
methodName: MethodName,
|
|
517
|
+
options?: MockFunctionOptions,
|
|
518
|
+
): MockedObject[MethodName] extends Function
|
|
519
|
+
? Mock<MockedObject[MethodName]>
|
|
520
|
+
: never;
|
|
521
|
+
method<
|
|
522
|
+
MockedObject extends object,
|
|
523
|
+
MethodName extends FunctionPropertyNames<MockedObject>,
|
|
524
|
+
Implementation extends Function,
|
|
525
|
+
>(
|
|
526
|
+
object: MockedObject,
|
|
527
|
+
methodName: MethodName,
|
|
528
|
+
implementation: Implementation,
|
|
529
|
+
options?: MockFunctionOptions,
|
|
530
|
+
): MockedObject[MethodName] extends Function
|
|
531
|
+
? Mock<MockedObject[MethodName] | Implementation>
|
|
532
|
+
: never;
|
|
533
|
+
method<MockedObject extends object>(
|
|
534
|
+
object: MockedObject,
|
|
535
|
+
methodName: keyof MockedObject,
|
|
536
|
+
options: MockMethodOptions,
|
|
537
|
+
): Mock<Function>;
|
|
538
|
+
method<MockedObject extends object>(
|
|
539
|
+
object: MockedObject,
|
|
540
|
+
methodName: keyof MockedObject,
|
|
541
|
+
implementation: Function,
|
|
542
|
+
options: MockMethodOptions,
|
|
543
|
+
): Mock<Function>;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.getter` set to `true`.
|
|
547
|
+
*/
|
|
548
|
+
getter<
|
|
549
|
+
MockedObject extends object,
|
|
550
|
+
MethodName extends keyof MockedObject,
|
|
551
|
+
>(
|
|
552
|
+
object: MockedObject,
|
|
553
|
+
methodName: MethodName,
|
|
554
|
+
options?: MockFunctionOptions,
|
|
555
|
+
): Mock<() => MockedObject[MethodName]>;
|
|
556
|
+
getter<
|
|
557
|
+
MockedObject extends object,
|
|
558
|
+
MethodName extends keyof MockedObject,
|
|
559
|
+
Implementation extends Function,
|
|
560
|
+
>(
|
|
561
|
+
object: MockedObject,
|
|
562
|
+
methodName: MethodName,
|
|
563
|
+
implementation?: Implementation,
|
|
564
|
+
options?: MockFunctionOptions,
|
|
565
|
+
): Mock<(() => MockedObject[MethodName]) | Implementation>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* This function is syntax sugar for {@link MockTracker.method} with `options.setter` set to `true`.
|
|
569
|
+
*/
|
|
570
|
+
setter<
|
|
571
|
+
MockedObject extends object,
|
|
572
|
+
MethodName extends keyof MockedObject,
|
|
573
|
+
>(
|
|
574
|
+
object: MockedObject,
|
|
575
|
+
methodName: MethodName,
|
|
576
|
+
options?: MockFunctionOptions,
|
|
577
|
+
): Mock<(value: MockedObject[MethodName]) => void>;
|
|
578
|
+
setter<
|
|
579
|
+
MockedObject extends object,
|
|
580
|
+
MethodName extends keyof MockedObject,
|
|
581
|
+
Implementation extends Function,
|
|
582
|
+
>(
|
|
583
|
+
object: MockedObject,
|
|
584
|
+
methodName: MethodName,
|
|
585
|
+
implementation?: Implementation,
|
|
586
|
+
options?: MockFunctionOptions,
|
|
587
|
+
): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`
|
|
591
|
+
* and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used,
|
|
592
|
+
* but the `MockTracker` instance can no longer be used to reset their behavior or otherwise interact with them.
|
|
593
|
+
*
|
|
594
|
+
* After each test completes, this function is called on the test context's `MockTracker`.
|
|
595
|
+
* If the global `MockTracker` is used extensively, calling this function manually is recommended.
|
|
596
|
+
*/
|
|
597
|
+
reset(): void;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* This function restores the default behavior of all mocks that were previously created by this `MockTracker`.
|
|
601
|
+
* Unlike `mock.reset()`, `mock.restoreAll()` does not disassociate the mocks from the `MockTracker` instance.
|
|
602
|
+
*/
|
|
603
|
+
restoreAll(): void;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const mock: MockTracker;
|
|
607
|
+
|
|
608
|
+
interface MockFunctionCall<
|
|
609
|
+
F extends Function,
|
|
610
|
+
ReturnType = F extends (...args: any) => infer T
|
|
611
|
+
? T
|
|
612
|
+
: F extends abstract new (...args: any) => infer T
|
|
613
|
+
? T
|
|
614
|
+
: unknown,
|
|
615
|
+
Args = F extends (...args: infer Y) => any
|
|
616
|
+
? Y
|
|
617
|
+
: F extends abstract new (...args: infer Y) => any
|
|
618
|
+
? Y
|
|
619
|
+
: unknown[],
|
|
620
|
+
> {
|
|
621
|
+
/**
|
|
622
|
+
* An array of the arguments passed to the mock function.
|
|
623
|
+
*/
|
|
624
|
+
arguments: Args;
|
|
625
|
+
/**
|
|
626
|
+
* If the mocked function threw then this property contains the thrown value.
|
|
627
|
+
*/
|
|
628
|
+
error: unknown | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* The value returned by the mocked function.
|
|
631
|
+
*
|
|
632
|
+
* If the mocked function threw, it will be `undefined`.
|
|
633
|
+
*/
|
|
634
|
+
result: ReturnType | undefined;
|
|
635
|
+
/**
|
|
636
|
+
* An `Error` object whose stack can be used to determine the callsite of the mocked function invocation.
|
|
637
|
+
*/
|
|
638
|
+
stack: Error;
|
|
639
|
+
/**
|
|
640
|
+
* If the mocked function is a constructor, this field contains the class being constructed.
|
|
641
|
+
* Otherwise this will be `undefined`.
|
|
642
|
+
*/
|
|
643
|
+
target: F extends abstract new (...args: any) => any ? F : undefined;
|
|
644
|
+
/**
|
|
645
|
+
* The mocked function's `this` value.
|
|
646
|
+
*/
|
|
647
|
+
this: unknown;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
interface MockFunctionContext<F extends Function> {
|
|
651
|
+
/**
|
|
652
|
+
* A getter that returns a copy of the internal array used to track calls to the mock.
|
|
653
|
+
*/
|
|
654
|
+
readonly calls: Array<MockFunctionCall<F>>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* This function returns the number of times that this mock has been invoked.
|
|
658
|
+
* This function is more efficient than checking `ctx.calls.length`
|
|
659
|
+
* because `ctx.calls` is a getter that creates a copy of the internal call tracking array.
|
|
660
|
+
*/
|
|
661
|
+
callCount(): number;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* This function is used to change the behavior of an existing mock.
|
|
665
|
+
* @param implementation The function to be used as the mock's new implementation.
|
|
666
|
+
*/
|
|
667
|
+
mockImplementation(implementation: Function): void;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* This function is used to change the behavior of an existing mock for a single invocation.
|
|
671
|
+
* Once invocation `onCall` has occurred, the mock will revert to whatever behavior
|
|
672
|
+
* it would have used had `mockImplementationOnce()` not been called.
|
|
673
|
+
* @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
|
|
674
|
+
* @param onCall The invocation number that will use `implementation`.
|
|
675
|
+
* If the specified invocation has already occurred then an exception is thrown.
|
|
676
|
+
*/
|
|
677
|
+
mockImplementationOnce(implementation: Function, onCall?: number): void;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Resets the call history of the mock function.
|
|
681
|
+
*/
|
|
682
|
+
resetCalls(): void;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Resets the implementation of the mock function to its original behavior.
|
|
686
|
+
* The mock can still be used after calling this function.
|
|
687
|
+
*/
|
|
688
|
+
restore(): void;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock };
|
|
446
692
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# readable-stream
|
|
2
2
|
|
|
3
|
-
***Node-core v8.
|
|
3
|
+
***Node-core v8.17.0 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[](https://nodei.co/npm/readable-stream/)
|
|
@@ -18,7 +18,7 @@ npm install --save readable-stream
|
|
|
18
18
|
This package is a mirror of the Streams2 and Streams3 implementations in
|
|
19
19
|
Node-core.
|
|
20
20
|
|
|
21
|
-
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.
|
|
21
|
+
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.17.0/docs/api/stream.html).
|
|
22
22
|
|
|
23
23
|
If you want to guarantee a stable streams base, regardless of what version of
|
|
24
24
|
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
|
@@ -53,7 +53,7 @@ var Stream = require('./internal/streams/stream');
|
|
|
53
53
|
/*<replacement>*/
|
|
54
54
|
|
|
55
55
|
var Buffer = require('safe-buffer').Buffer;
|
|
56
|
-
var OurUint8Array = global.Uint8Array || function () {};
|
|
56
|
+
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
57
57
|
function _uint8ArrayToBuffer(chunk) {
|
|
58
58
|
return Buffer.from(chunk);
|
|
59
59
|
}
|
|
@@ -623,8 +623,8 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
|
623
623
|
// also returned false.
|
|
624
624
|
// => Check whether `dest` is still a piping destination.
|
|
625
625
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
626
|
-
debug('false write response, pause',
|
|
627
|
-
|
|
626
|
+
debug('false write response, pause', state.awaitDrain);
|
|
627
|
+
state.awaitDrain++;
|
|
628
628
|
increasedAwaitDrain = true;
|
|
629
629
|
}
|
|
630
630
|
src.pause();
|
|
@@ -718,7 +718,7 @@ Readable.prototype.unpipe = function (dest) {
|
|
|
718
718
|
state.flowing = false;
|
|
719
719
|
|
|
720
720
|
for (var i = 0; i < len; i++) {
|
|
721
|
-
dests[i].emit('unpipe', this,
|
|
721
|
+
dests[i].emit('unpipe', this, { hasUnpiped: false });
|
|
722
722
|
}return this;
|
|
723
723
|
}
|
|
724
724
|
|
|
@@ -81,7 +81,7 @@ var Stream = require('./internal/streams/stream');
|
|
|
81
81
|
/*<replacement>*/
|
|
82
82
|
|
|
83
83
|
var Buffer = require('safe-buffer').Buffer;
|
|
84
|
-
var OurUint8Array = global.Uint8Array || function () {};
|
|
84
|
+
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
85
85
|
function _uint8ArrayToBuffer(chunk) {
|
|
86
86
|
return Buffer.from(chunk);
|
|
87
87
|
}
|
|
@@ -349,7 +349,7 @@ Writable.prototype.uncork = function () {
|
|
|
349
349
|
if (state.corked) {
|
|
350
350
|
state.corked--;
|
|
351
351
|
|
|
352
|
-
if (!state.writing && !state.corked && !state.
|
|
352
|
+
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
355
|
|
|
@@ -591,7 +591,7 @@ Writable.prototype.end = function (chunk, encoding, cb) {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
// ignore unnecessary end() calls.
|
|
594
|
-
if (!state.ending
|
|
594
|
+
if (!state.ending) endWritable(this, state, cb);
|
|
595
595
|
};
|
|
596
596
|
|
|
597
597
|
function needFinish(state) {
|
|
@@ -652,11 +652,9 @@ function onCorkedFinish(corkReq, state, err) {
|
|
|
652
652
|
cb(err);
|
|
653
653
|
entry = entry.next;
|
|
654
654
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
state.corkedRequestsFree = corkReq;
|
|
659
|
-
}
|
|
655
|
+
|
|
656
|
+
// reuse the free corkReq.
|
|
657
|
+
state.corkedRequestsFree.next = corkReq;
|
|
660
658
|
}
|
|
661
659
|
|
|
662
660
|
Object.defineProperty(Writable.prototype, 'destroyed', {
|
package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/BufferList.js
CHANGED
|
@@ -56,7 +56,6 @@ module.exports = function () {
|
|
|
56
56
|
|
|
57
57
|
BufferList.prototype.concat = function concat(n) {
|
|
58
58
|
if (this.length === 0) return Buffer.alloc(0);
|
|
59
|
-
if (this.length === 1) return this.head.data;
|
|
60
59
|
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
61
60
|
var p = this.head;
|
|
62
61
|
var i = 0;
|
package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/destroy.js
CHANGED
|
@@ -15,9 +15,15 @@ function destroy(err, cb) {
|
|
|
15
15
|
if (readableDestroyed || writableDestroyed) {
|
|
16
16
|
if (cb) {
|
|
17
17
|
cb(err);
|
|
18
|
-
} else if (err
|
|
19
|
-
|
|
18
|
+
} else if (err) {
|
|
19
|
+
if (!this._writableState) {
|
|
20
|
+
pna.nextTick(emitErrorNT, this, err);
|
|
21
|
+
} else if (!this._writableState.errorEmitted) {
|
|
22
|
+
this._writableState.errorEmitted = true;
|
|
23
|
+
pna.nextTick(emitErrorNT, this, err);
|
|
24
|
+
}
|
|
20
25
|
}
|
|
26
|
+
|
|
21
27
|
return this;
|
|
22
28
|
}
|
|
23
29
|
|
|
@@ -35,9 +41,11 @@ function destroy(err, cb) {
|
|
|
35
41
|
|
|
36
42
|
this._destroy(err || null, function (err) {
|
|
37
43
|
if (!cb && err) {
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
if (!_this._writableState) {
|
|
45
|
+
pna.nextTick(emitErrorNT, _this, err);
|
|
46
|
+
} else if (!_this._writableState.errorEmitted) {
|
|
40
47
|
_this._writableState.errorEmitted = true;
|
|
48
|
+
pna.nextTick(emitErrorNT, _this, err);
|
|
41
49
|
}
|
|
42
50
|
} else if (cb) {
|
|
43
51
|
cb(err);
|
|
@@ -59,6 +67,8 @@ function undestroy() {
|
|
|
59
67
|
this._writableState.destroyed = false;
|
|
60
68
|
this._writableState.ended = false;
|
|
61
69
|
this._writableState.ending = false;
|
|
70
|
+
this._writableState.finalCalled = false;
|
|
71
|
+
this._writableState.prefinished = false;
|
|
62
72
|
this._writableState.finished = false;
|
|
63
73
|
this._writableState.errorEmitted = false;
|
|
64
74
|
}
|
package/package.json
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"jsii-docgen": "^3.8.31",
|
|
55
55
|
"jsii-pacmak": "^1.75.0",
|
|
56
56
|
"npm-check-updates": "^16",
|
|
57
|
-
"projen": "0.67.
|
|
57
|
+
"projen": "0.67.64",
|
|
58
58
|
"standard-version": "^9",
|
|
59
59
|
"ts-jest": "^27",
|
|
60
60
|
"typescript": "3.9.10"
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
],
|
|
83
83
|
"main": "lib/index.js",
|
|
84
84
|
"license": "Apache-2.0",
|
|
85
|
-
"version": "2.0.
|
|
85
|
+
"version": "2.0.418",
|
|
86
86
|
"jest": {
|
|
87
87
|
"testMatch": [
|
|
88
88
|
"<rootDir>/src/**/__tests__/**/*.ts?(x)",
|