@mtkruto/node 0.0.971 → 0.0.973

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.
Files changed (135) hide show
  1. package/esm/constants.d.ts +1 -1
  2. package/esm/constants.js +1 -1
  3. package/esm/deps/deno.land/std@0.196.0/assert/_constants.d.ts +1 -0
  4. package/esm/deps/deno.land/std@0.196.0/assert/_constants.js +2 -0
  5. package/esm/deps/deno.land/std@0.196.0/assert/assert.d.ts +2 -0
  6. package/esm/deps/deno.land/std@0.196.0/assert/assert.js +8 -0
  7. package/esm/deps/deno.land/std@0.196.0/assert/assert_almost_equals.d.ts +18 -0
  8. package/esm/deps/deno.land/std@0.196.0/assert/assert_almost_equals.js +32 -0
  9. package/esm/deps/deno.land/std@0.196.0/assert/assert_array_includes.d.ts +14 -0
  10. package/esm/deps/deno.land/std@0.196.0/assert/assert_array_includes.js +38 -0
  11. package/esm/deps/deno.land/std@0.196.0/assert/assert_equals.d.ts +17 -0
  12. package/esm/deps/deno.land/std@0.196.0/assert/assert_equals.js +45 -0
  13. package/esm/deps/deno.land/std@0.196.0/assert/assert_exists.d.ts +5 -0
  14. package/esm/deps/deno.land/std@0.196.0/assert/assert_exists.js +14 -0
  15. package/esm/deps/deno.land/std@0.196.0/assert/assert_false.d.ts +4 -0
  16. package/esm/deps/deno.land/std@0.196.0/assert/assert_false.js +7 -0
  17. package/esm/deps/deno.land/std@0.196.0/assert/assert_instance_of.d.ts +8 -0
  18. package/esm/deps/deno.land/std@0.196.0/assert/assert_instance_of.js +38 -0
  19. package/esm/deps/deno.land/std@0.196.0/assert/assert_is_error.d.ts +7 -0
  20. package/esm/deps/deno.land/std@0.196.0/assert/assert_is_error.js +26 -0
  21. package/esm/deps/deno.land/std@0.196.0/assert/assert_match.d.ts +5 -0
  22. package/esm/deps/deno.land/std@0.196.0/assert/assert_match.js +13 -0
  23. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_equals.d.ts +14 -0
  24. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_equals.js +37 -0
  25. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_instance_of.d.ts +5 -0
  26. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_instance_of.js +14 -0
  27. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_match.d.ts +5 -0
  28. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_match.js +14 -0
  29. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_strict_equals.d.ts +11 -0
  30. package/esm/deps/deno.land/std@0.196.0/assert/assert_not_strict_equals.js +20 -0
  31. package/esm/deps/deno.land/std@0.196.0/assert/assert_object_match.d.ts +5 -0
  32. package/esm/deps/deno.land/std@0.196.0/assert/assert_object_match.js +78 -0
  33. package/esm/deps/deno.land/std@0.196.0/assert/assert_rejects.d.ts +64 -0
  34. package/esm/deps/deno.land/std@0.196.0/assert/assert_rejects.js +50 -0
  35. package/esm/deps/deno.land/std@0.196.0/assert/assert_strict_equals.d.ts +23 -0
  36. package/esm/deps/deno.land/std@0.196.0/assert/assert_strict_equals.js +60 -0
  37. package/esm/deps/deno.land/std@0.196.0/assert/assert_string_includes.d.ts +5 -0
  38. package/esm/deps/deno.land/std@0.196.0/assert/assert_string_includes.js +13 -0
  39. package/esm/deps/deno.land/std@0.196.0/assert/assert_throws.d.ts +54 -0
  40. package/esm/deps/deno.land/std@0.196.0/assert/assert_throws.js +44 -0
  41. package/esm/deps/deno.land/std@0.196.0/assert/assertion_error.d.ts +4 -0
  42. package/esm/deps/deno.land/std@0.196.0/assert/assertion_error.js +12 -0
  43. package/esm/deps/deno.land/std@0.196.0/assert/equal.d.ts +6 -0
  44. package/esm/deps/deno.land/std@0.196.0/assert/equal.js +102 -0
  45. package/esm/deps/deno.land/std@0.196.0/assert/fail.d.ts +4 -0
  46. package/esm/deps/deno.land/std@0.196.0/assert/fail.js +9 -0
  47. package/esm/deps/deno.land/std@0.196.0/assert/mod.d.ts +32 -0
  48. package/esm/deps/deno.land/std@0.196.0/assert/mod.js +33 -0
  49. package/esm/deps/deno.land/std@0.196.0/assert/unimplemented.d.ts +2 -0
  50. package/esm/deps/deno.land/std@0.196.0/assert/unimplemented.js +7 -0
  51. package/esm/deps/deno.land/std@0.196.0/assert/unreachable.d.ts +2 -0
  52. package/esm/deps/deno.land/std@0.196.0/assert/unreachable.js +6 -0
  53. package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.js +2 -2
  54. package/{script/deps/deno.land/std@0.190.0 → esm/deps/deno.land/std@0.196.0}/testing/asserts.d.ts +204 -159
  55. package/esm/deps/deno.land/std@0.196.0/testing/asserts.js +330 -0
  56. package/esm/deps.d.ts +2 -2
  57. package/esm/deps.js +2 -2
  58. package/esm/storage/0_storage.d.ts +1 -1
  59. package/esm/storage/0_storage.js +7 -2
  60. package/package.json +1 -1
  61. package/script/constants.d.ts +1 -1
  62. package/script/constants.js +1 -1
  63. package/script/deps/deno.land/std@0.196.0/assert/_constants.d.ts +1 -0
  64. package/script/deps/deno.land/std@0.196.0/assert/_constants.js +5 -0
  65. package/script/deps/deno.land/std@0.196.0/assert/assert.d.ts +2 -0
  66. package/script/deps/deno.land/std@0.196.0/assert/assert.js +12 -0
  67. package/script/deps/deno.land/std@0.196.0/assert/assert_almost_equals.d.ts +18 -0
  68. package/script/deps/deno.land/std@0.196.0/assert/assert_almost_equals.js +36 -0
  69. package/script/deps/deno.land/std@0.196.0/assert/assert_array_includes.d.ts +14 -0
  70. package/script/deps/deno.land/std@0.196.0/assert/assert_array_includes.js +42 -0
  71. package/script/deps/deno.land/std@0.196.0/assert/assert_equals.d.ts +17 -0
  72. package/script/deps/deno.land/std@0.196.0/assert/assert_equals.js +49 -0
  73. package/script/deps/deno.land/std@0.196.0/assert/assert_exists.d.ts +5 -0
  74. package/script/deps/deno.land/std@0.196.0/assert/assert_exists.js +18 -0
  75. package/script/deps/deno.land/std@0.196.0/assert/assert_false.d.ts +4 -0
  76. package/script/deps/deno.land/std@0.196.0/assert/assert_false.js +11 -0
  77. package/script/deps/deno.land/std@0.196.0/assert/assert_instance_of.d.ts +8 -0
  78. package/script/deps/deno.land/std@0.196.0/assert/assert_instance_of.js +42 -0
  79. package/script/deps/deno.land/std@0.196.0/assert/assert_is_error.d.ts +7 -0
  80. package/script/deps/deno.land/std@0.196.0/assert/assert_is_error.js +30 -0
  81. package/script/deps/deno.land/std@0.196.0/assert/assert_match.d.ts +5 -0
  82. package/script/deps/deno.land/std@0.196.0/assert/assert_match.js +17 -0
  83. package/script/deps/deno.land/std@0.196.0/assert/assert_not_equals.d.ts +14 -0
  84. package/script/deps/deno.land/std@0.196.0/assert/assert_not_equals.js +41 -0
  85. package/script/deps/deno.land/std@0.196.0/assert/assert_not_instance_of.d.ts +5 -0
  86. package/script/deps/deno.land/std@0.196.0/assert/assert_not_instance_of.js +18 -0
  87. package/script/deps/deno.land/std@0.196.0/assert/assert_not_match.d.ts +5 -0
  88. package/script/deps/deno.land/std@0.196.0/assert/assert_not_match.js +18 -0
  89. package/script/deps/deno.land/std@0.196.0/assert/assert_not_strict_equals.d.ts +11 -0
  90. package/script/deps/deno.land/std@0.196.0/assert/assert_not_strict_equals.js +24 -0
  91. package/script/deps/deno.land/std@0.196.0/assert/assert_object_match.d.ts +5 -0
  92. package/script/deps/deno.land/std@0.196.0/assert/assert_object_match.js +82 -0
  93. package/script/deps/deno.land/std@0.196.0/assert/assert_rejects.d.ts +64 -0
  94. package/script/deps/deno.land/std@0.196.0/assert/assert_rejects.js +54 -0
  95. package/script/deps/deno.land/std@0.196.0/assert/assert_strict_equals.d.ts +23 -0
  96. package/script/deps/deno.land/std@0.196.0/assert/assert_strict_equals.js +64 -0
  97. package/script/deps/deno.land/std@0.196.0/assert/assert_string_includes.d.ts +5 -0
  98. package/script/deps/deno.land/std@0.196.0/assert/assert_string_includes.js +17 -0
  99. package/script/deps/deno.land/std@0.196.0/assert/assert_throws.d.ts +54 -0
  100. package/script/deps/deno.land/std@0.196.0/assert/assert_throws.js +48 -0
  101. package/script/deps/deno.land/std@0.196.0/assert/assertion_error.d.ts +4 -0
  102. package/script/deps/deno.land/std@0.196.0/assert/assertion_error.js +16 -0
  103. package/script/deps/deno.land/std@0.196.0/assert/equal.d.ts +6 -0
  104. package/script/deps/deno.land/std@0.196.0/assert/equal.js +106 -0
  105. package/script/deps/deno.land/std@0.196.0/assert/fail.d.ts +4 -0
  106. package/script/deps/deno.land/std@0.196.0/assert/fail.js +13 -0
  107. package/script/deps/deno.land/std@0.196.0/assert/mod.d.ts +32 -0
  108. package/script/deps/deno.land/std@0.196.0/assert/mod.js +49 -0
  109. package/script/deps/deno.land/std@0.196.0/assert/unimplemented.d.ts +2 -0
  110. package/script/deps/deno.land/std@0.196.0/assert/unimplemented.js +11 -0
  111. package/script/deps/deno.land/std@0.196.0/assert/unreachable.d.ts +2 -0
  112. package/script/deps/deno.land/std@0.196.0/assert/unreachable.js +10 -0
  113. package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.js +2 -2
  114. package/{esm/deps/deno.land/std@0.190.0 → script/deps/deno.land/std@0.196.0}/testing/asserts.d.ts +204 -159
  115. package/script/deps/deno.land/std@0.196.0/testing/asserts.js +333 -0
  116. package/script/deps.d.ts +2 -2
  117. package/script/deps.js +2 -2
  118. package/script/storage/0_storage.d.ts +1 -1
  119. package/script/storage/0_storage.js +7 -2
  120. package/esm/deps/deno.land/std@0.190.0/testing/asserts.js +0 -633
  121. package/script/deps/deno.land/std@0.190.0/testing/asserts.js +0 -659
  122. /package/esm/deps/deno.land/{std@0.190.0/testing/_diff.d.ts → std@0.196.0/_util/diff.d.ts} +0 -0
  123. /package/esm/deps/deno.land/{std@0.190.0/testing/_diff.js → std@0.196.0/_util/diff.js} +0 -0
  124. /package/esm/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.d.ts +0 -0
  125. /package/esm/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.js +0 -0
  126. /package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.d.ts +0 -0
  127. /package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.js +0 -0
  128. /package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.d.ts +0 -0
  129. /package/script/deps/deno.land/{std@0.190.0/testing/_diff.d.ts → std@0.196.0/_util/diff.d.ts} +0 -0
  130. /package/script/deps/deno.land/{std@0.190.0/testing/_diff.js → std@0.196.0/_util/diff.js} +0 -0
  131. /package/script/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.d.ts +0 -0
  132. /package/script/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.js +0 -0
  133. /package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.d.ts +0 -0
  134. /package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.js +0 -0
  135. /package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.d.ts +0 -0
@@ -0,0 +1,50 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { AssertionError } from "./assertion_error.js";
3
+ import { assertIsError } from "./assert_is_error.js";
4
+ export async function assertRejects(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
5
+ // deno-lint-ignore no-explicit-any
6
+ let ErrorClass = undefined;
7
+ let msgIncludes = undefined;
8
+ let err;
9
+ if (typeof errorClassOrMsg !== "string") {
10
+ if (errorClassOrMsg === undefined ||
11
+ errorClassOrMsg.prototype instanceof Error ||
12
+ errorClassOrMsg.prototype === Error.prototype) {
13
+ // deno-lint-ignore no-explicit-any
14
+ ErrorClass = errorClassOrMsg;
15
+ msgIncludes = msgIncludesOrMsg;
16
+ }
17
+ }
18
+ else {
19
+ msg = errorClassOrMsg;
20
+ }
21
+ let doesThrow = false;
22
+ let isPromiseReturned = false;
23
+ const msgSuffix = msg ? `: ${msg}` : ".";
24
+ try {
25
+ const possiblePromise = fn();
26
+ if (possiblePromise &&
27
+ typeof possiblePromise === "object" &&
28
+ typeof possiblePromise.then === "function") {
29
+ isPromiseReturned = true;
30
+ await possiblePromise;
31
+ }
32
+ }
33
+ catch (error) {
34
+ if (!isPromiseReturned) {
35
+ throw new AssertionError(`Function throws when expected to reject${msgSuffix}`);
36
+ }
37
+ if (ErrorClass) {
38
+ if (error instanceof Error === false) {
39
+ throw new AssertionError(`A non-Error object was rejected${msgSuffix}`);
40
+ }
41
+ assertIsError(error, ErrorClass, msgIncludes, msg);
42
+ }
43
+ err = error;
44
+ doesThrow = true;
45
+ }
46
+ if (!doesThrow) {
47
+ throw new AssertionError(`Expected function to reject${msgSuffix}`);
48
+ }
49
+ return err;
50
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Make an assertion that `actual` and `expected` are strictly equal. If
3
+ * not then throw.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { assertStrictEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_strict_equals.ts";
8
+ *
9
+ * Deno.test("isStrictlyEqual", function (): void {
10
+ * const a = {};
11
+ * const b = a;
12
+ * assertStrictEquals(a, b);
13
+ * });
14
+ *
15
+ * // This test fails
16
+ * Deno.test("isNotStrictlyEqual", function (): void {
17
+ * const a = {};
18
+ * const b = {};
19
+ * assertStrictEquals(a, b);
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T;
@@ -0,0 +1,60 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { format } from "./_format.js";
3
+ import { AssertionError } from "./assertion_error.js";
4
+ import { buildMessage, diff, diffstr } from "../_util/diff.js";
5
+ import { CAN_NOT_DISPLAY } from "./_constants.js";
6
+ import { red } from "../fmt/colors.js";
7
+ /**
8
+ * Make an assertion that `actual` and `expected` are strictly equal. If
9
+ * not then throw.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { assertStrictEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_strict_equals.ts";
14
+ *
15
+ * Deno.test("isStrictlyEqual", function (): void {
16
+ * const a = {};
17
+ * const b = a;
18
+ * assertStrictEquals(a, b);
19
+ * });
20
+ *
21
+ * // This test fails
22
+ * Deno.test("isNotStrictlyEqual", function (): void {
23
+ * const a = {};
24
+ * const b = {};
25
+ * assertStrictEquals(a, b);
26
+ * });
27
+ * ```
28
+ */
29
+ export function assertStrictEquals(actual, expected, msg) {
30
+ if (Object.is(actual, expected)) {
31
+ return;
32
+ }
33
+ const msgSuffix = msg ? `: ${msg}` : ".";
34
+ let message;
35
+ const actualString = format(actual);
36
+ const expectedString = format(expected);
37
+ if (actualString === expectedString) {
38
+ const withOffset = actualString
39
+ .split("\n")
40
+ .map((l) => ` ${l}`)
41
+ .join("\n");
42
+ message =
43
+ `Values have the same structure but are not reference-equal${msgSuffix}\n\n${red(withOffset)}\n`;
44
+ }
45
+ else {
46
+ try {
47
+ const stringDiff = (typeof actual === "string") &&
48
+ (typeof expected === "string");
49
+ const diffResult = stringDiff
50
+ ? diffstr(actual, expected)
51
+ : diff(actualString.split("\n"), expectedString.split("\n"));
52
+ const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
53
+ message = `Values are not strictly equal${msgSuffix}\n${diffMsg}`;
54
+ }
55
+ catch {
56
+ message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
57
+ }
58
+ }
59
+ throw new AssertionError(message);
60
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that actual includes expected. If not
3
+ * then throw.
4
+ */
5
+ export declare function assertStringIncludes(actual: string, expected: string, msg?: string): void;
@@ -0,0 +1,13 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { AssertionError } from "./assertion_error.js";
3
+ /**
4
+ * Make an assertion that actual includes expected. If not
5
+ * then throw.
6
+ */
7
+ export function assertStringIncludes(actual, expected, msg) {
8
+ if (!actual.includes(expected)) {
9
+ const msgSuffix = msg ? `: ${msg}` : ".";
10
+ msg = `Expected actual: "${actual}" to contain: "${expected}"${msgSuffix}`;
11
+ throw new AssertionError(msg);
12
+ }
13
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Executes a function, expecting it to throw. If it does not, then it
3
+ * throws.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { assertThrows } from "https://deno.land/std@$STD_VERSION/assert/assert_throws.ts";
8
+ *
9
+ * Deno.test("doesThrow", function (): void {
10
+ * assertThrows((): void => {
11
+ * throw new TypeError("hello world!");
12
+ * });
13
+ * });
14
+ *
15
+ * // This test will not pass.
16
+ * Deno.test("fails", function (): void {
17
+ * assertThrows((): void => {
18
+ * console.log("Hello world");
19
+ * });
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function assertThrows(fn: () => unknown, msg?: string): unknown;
24
+ /**
25
+ * Executes a function, expecting it to throw. If it does not, then it
26
+ * throws. An error class and a string that should be included in the
27
+ * error message can also be asserted.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { assertThrows } from "https://deno.land/std@$STD_VERSION/assert/assert_throws.ts";
32
+ *
33
+ * Deno.test("doesThrow", function (): void {
34
+ * assertThrows((): void => {
35
+ * throw new TypeError("hello world!");
36
+ * }, TypeError);
37
+ * assertThrows(
38
+ * (): void => {
39
+ * throw new TypeError("hello world!");
40
+ * },
41
+ * TypeError,
42
+ * "hello",
43
+ * );
44
+ * });
45
+ *
46
+ * // This test will not pass.
47
+ * Deno.test("fails", function (): void {
48
+ * assertThrows((): void => {
49
+ * console.log("Hello world");
50
+ * });
51
+ * });
52
+ * ```
53
+ */
54
+ export declare function assertThrows<E extends Error = Error>(fn: () => unknown, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): E;
@@ -0,0 +1,44 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { assertIsError } from "./assert_is_error.js";
3
+ import { AssertionError } from "./assertion_error.js";
4
+ export function assertThrows(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
5
+ // deno-lint-ignore no-explicit-any
6
+ let ErrorClass = undefined;
7
+ let msgIncludes = undefined;
8
+ let err;
9
+ if (typeof errorClassOrMsg !== "string") {
10
+ if (errorClassOrMsg === undefined ||
11
+ errorClassOrMsg.prototype instanceof Error ||
12
+ errorClassOrMsg.prototype === Error.prototype) {
13
+ // deno-lint-ignore no-explicit-any
14
+ ErrorClass = errorClassOrMsg;
15
+ msgIncludes = msgIncludesOrMsg;
16
+ }
17
+ else {
18
+ msg = msgIncludesOrMsg;
19
+ }
20
+ }
21
+ else {
22
+ msg = errorClassOrMsg;
23
+ }
24
+ let doesThrow = false;
25
+ const msgSuffix = msg ? `: ${msg}` : ".";
26
+ try {
27
+ fn();
28
+ }
29
+ catch (error) {
30
+ if (ErrorClass) {
31
+ if (error instanceof Error === false) {
32
+ throw new AssertionError(`A non-Error object was thrown${msgSuffix}`);
33
+ }
34
+ assertIsError(error, ErrorClass, msgIncludes, msg);
35
+ }
36
+ err = error;
37
+ doesThrow = true;
38
+ }
39
+ if (!doesThrow) {
40
+ msg = `Expected function to throw${msgSuffix}`;
41
+ throw new AssertionError(msg);
42
+ }
43
+ return err;
44
+ }
@@ -0,0 +1,4 @@
1
+ export declare class AssertionError extends Error {
2
+ name: string;
3
+ constructor(message: string);
4
+ }
@@ -0,0 +1,12 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ export class AssertionError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ Object.defineProperty(this, "name", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: "AssertionError"
10
+ });
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Deep equality comparison used in assertions
3
+ * @param c actual value
4
+ * @param d expected value
5
+ */
6
+ export declare function equal(c: unknown, d: unknown): boolean;
@@ -0,0 +1,102 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ function isKeyedCollection(x) {
3
+ return [Symbol.iterator, "size"].every((k) => k in x);
4
+ }
5
+ function constructorsEqual(a, b) {
6
+ return a.constructor === b.constructor ||
7
+ a.constructor === Object && !b.constructor ||
8
+ !a.constructor && b.constructor === Object;
9
+ }
10
+ /**
11
+ * Deep equality comparison used in assertions
12
+ * @param c actual value
13
+ * @param d expected value
14
+ */
15
+ export function equal(c, d) {
16
+ const seen = new Map();
17
+ return (function compare(a, b) {
18
+ // Have to render RegExp & Date for string comparison
19
+ // unless it's mistreated as object
20
+ if (a &&
21
+ b &&
22
+ ((a instanceof RegExp && b instanceof RegExp) ||
23
+ (a instanceof URL && b instanceof URL))) {
24
+ return String(a) === String(b);
25
+ }
26
+ if (a instanceof Date && b instanceof Date) {
27
+ const aTime = a.getTime();
28
+ const bTime = b.getTime();
29
+ // Check for NaN equality manually since NaN is not
30
+ // equal to itself.
31
+ if (Number.isNaN(aTime) && Number.isNaN(bTime)) {
32
+ return true;
33
+ }
34
+ return aTime === bTime;
35
+ }
36
+ if (typeof a === "number" && typeof b === "number") {
37
+ return Number.isNaN(a) && Number.isNaN(b) || a === b;
38
+ }
39
+ if (Object.is(a, b)) {
40
+ return true;
41
+ }
42
+ if (a && typeof a === "object" && b && typeof b === "object") {
43
+ if (a && b && !constructorsEqual(a, b)) {
44
+ return false;
45
+ }
46
+ if (a instanceof WeakMap || b instanceof WeakMap) {
47
+ if (!(a instanceof WeakMap && b instanceof WeakMap))
48
+ return false;
49
+ throw new TypeError("cannot compare WeakMap instances");
50
+ }
51
+ if (a instanceof WeakSet || b instanceof WeakSet) {
52
+ if (!(a instanceof WeakSet && b instanceof WeakSet))
53
+ return false;
54
+ throw new TypeError("cannot compare WeakSet instances");
55
+ }
56
+ if (seen.get(a) === b) {
57
+ return true;
58
+ }
59
+ if (Object.keys(a || {}).length !== Object.keys(b || {}).length) {
60
+ return false;
61
+ }
62
+ seen.set(a, b);
63
+ if (isKeyedCollection(a) && isKeyedCollection(b)) {
64
+ if (a.size !== b.size) {
65
+ return false;
66
+ }
67
+ let unmatchedEntries = a.size;
68
+ for (const [aKey, aValue] of a.entries()) {
69
+ for (const [bKey, bValue] of b.entries()) {
70
+ /* Given that Map keys can be references, we need
71
+ * to ensure that they are also deeply equal */
72
+ if ((aKey === aValue && bKey === bValue && compare(aKey, bKey)) ||
73
+ (compare(aKey, bKey) && compare(aValue, bValue))) {
74
+ unmatchedEntries--;
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ return unmatchedEntries === 0;
80
+ }
81
+ const merged = { ...a, ...b };
82
+ for (const key of [
83
+ ...Object.getOwnPropertyNames(merged),
84
+ ...Object.getOwnPropertySymbols(merged),
85
+ ]) {
86
+ if (!compare(a && a[key], b && b[key])) {
87
+ return false;
88
+ }
89
+ if (((key in a) && (!(key in b))) || ((key in b) && (!(key in a)))) {
90
+ return false;
91
+ }
92
+ }
93
+ if (a instanceof WeakRef || b instanceof WeakRef) {
94
+ if (!(a instanceof WeakRef && b instanceof WeakRef))
95
+ return false;
96
+ return compare(a.deref(), b.deref());
97
+ }
98
+ return true;
99
+ }
100
+ return false;
101
+ })(c, d);
102
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Forcefully throws a failed assertion
3
+ */
4
+ export declare function fail(msg?: string): never;
@@ -0,0 +1,9 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { assert } from "./assert.js";
3
+ /**
4
+ * Forcefully throws a failed assertion
5
+ */
6
+ export function fail(msg) {
7
+ const msgSuffix = msg ? `: ${msg}` : ".";
8
+ assert(false, `Failed assertion${msgSuffix}`);
9
+ }
@@ -0,0 +1,32 @@
1
+ /** A library of assertion functions.
2
+ * If the assertion is false an `AssertionError` will be thrown which will
3
+ * result in pretty-printed diff of failing assertion.
4
+ *
5
+ * This module is browser compatible, but do not rely on good formatting of
6
+ * values for AssertionError messages in browsers.
7
+ *
8
+ * @module
9
+ */
10
+ export * from "./assert_almost_equals.js";
11
+ export * from "./assert_array_includes.js";
12
+ export * from "./assert_equals.js";
13
+ export * from "./assert_exists.js";
14
+ export * from "./assert_false.js";
15
+ export * from "./assert_instance_of.js";
16
+ export * from "./assert_is_error.js";
17
+ export * from "./assert_match.js";
18
+ export * from "./assert_not_equals.js";
19
+ export * from "./assert_not_instance_of.js";
20
+ export * from "./assert_not_match.js";
21
+ export * from "./assert_not_strict_equals.js";
22
+ export * from "./assert_object_match.js";
23
+ export * from "./assert_rejects.js";
24
+ export * from "./assert_strict_equals.js";
25
+ export * from "./assert_string_includes.js";
26
+ export * from "./assert_throws.js";
27
+ export * from "./assert.js";
28
+ export * from "./assertion_error.js";
29
+ export * from "./equal.js";
30
+ export * from "./fail.js";
31
+ export * from "./unimplemented.js";
32
+ export * from "./unreachable.js";
@@ -0,0 +1,33 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ /** A library of assertion functions.
3
+ * If the assertion is false an `AssertionError` will be thrown which will
4
+ * result in pretty-printed diff of failing assertion.
5
+ *
6
+ * This module is browser compatible, but do not rely on good formatting of
7
+ * values for AssertionError messages in browsers.
8
+ *
9
+ * @module
10
+ */
11
+ export * from "./assert_almost_equals.js";
12
+ export * from "./assert_array_includes.js";
13
+ export * from "./assert_equals.js";
14
+ export * from "./assert_exists.js";
15
+ export * from "./assert_false.js";
16
+ export * from "./assert_instance_of.js";
17
+ export * from "./assert_is_error.js";
18
+ export * from "./assert_match.js";
19
+ export * from "./assert_not_equals.js";
20
+ export * from "./assert_not_instance_of.js";
21
+ export * from "./assert_not_match.js";
22
+ export * from "./assert_not_strict_equals.js";
23
+ export * from "./assert_object_match.js";
24
+ export * from "./assert_rejects.js";
25
+ export * from "./assert_strict_equals.js";
26
+ export * from "./assert_string_includes.js";
27
+ export * from "./assert_throws.js";
28
+ export * from "./assert.js";
29
+ export * from "./assertion_error.js";
30
+ export * from "./equal.js";
31
+ export * from "./fail.js";
32
+ export * from "./unimplemented.js";
33
+ export * from "./unreachable.js";
@@ -0,0 +1,2 @@
1
+ /** Use this to stub out methods that will throw when invoked. */
2
+ export declare function unimplemented(msg?: string): never;
@@ -0,0 +1,7 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { AssertionError } from "./assertion_error.js";
3
+ /** Use this to stub out methods that will throw when invoked. */
4
+ export function unimplemented(msg) {
5
+ const msgSuffix = msg ? `: ${msg}` : ".";
6
+ throw new AssertionError(`Unimplemented${msgSuffix}`);
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Use this to assert unreachable code. */
2
+ export declare function unreachable(): never;
@@ -0,0 +1,6 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { AssertionError } from "./assertion_error.js";
3
+ /** Use this to assert unreachable code. */
4
+ export function unreachable() {
5
+ throw new AssertionError("unreachable");
6
+ }
@@ -53,14 +53,14 @@ import * as dntShim from "../../../../_dnt.shims.js";
53
53
  const { Deno } = dntShim.dntGlobalThis;
54
54
  const noColor = typeof Deno?.noColor === "boolean"
55
55
  ? Deno.noColor
56
- : true;
56
+ : false;
57
57
  let enabled = !noColor;
58
58
  /**
59
59
  * Set changing text color to enabled or disabled
60
60
  * @param value
61
61
  */
62
62
  export function setColorEnabled(value) {
63
- if (noColor) {
63
+ if (Deno?.noColor) {
64
64
  return;
65
65
  }
66
66
  enabled = value;