@mtkruto/node 0.0.970 → 0.0.972

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 (133) 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/tl/1_tl_object.js +1 -1
  59. package/package.json +1 -1
  60. package/script/constants.d.ts +1 -1
  61. package/script/constants.js +1 -1
  62. package/script/deps/deno.land/std@0.196.0/assert/_constants.d.ts +1 -0
  63. package/script/deps/deno.land/std@0.196.0/assert/_constants.js +5 -0
  64. package/script/deps/deno.land/std@0.196.0/assert/assert.d.ts +2 -0
  65. package/script/deps/deno.land/std@0.196.0/assert/assert.js +12 -0
  66. package/script/deps/deno.land/std@0.196.0/assert/assert_almost_equals.d.ts +18 -0
  67. package/script/deps/deno.land/std@0.196.0/assert/assert_almost_equals.js +36 -0
  68. package/script/deps/deno.land/std@0.196.0/assert/assert_array_includes.d.ts +14 -0
  69. package/script/deps/deno.land/std@0.196.0/assert/assert_array_includes.js +42 -0
  70. package/script/deps/deno.land/std@0.196.0/assert/assert_equals.d.ts +17 -0
  71. package/script/deps/deno.land/std@0.196.0/assert/assert_equals.js +49 -0
  72. package/script/deps/deno.land/std@0.196.0/assert/assert_exists.d.ts +5 -0
  73. package/script/deps/deno.land/std@0.196.0/assert/assert_exists.js +18 -0
  74. package/script/deps/deno.land/std@0.196.0/assert/assert_false.d.ts +4 -0
  75. package/script/deps/deno.land/std@0.196.0/assert/assert_false.js +11 -0
  76. package/script/deps/deno.land/std@0.196.0/assert/assert_instance_of.d.ts +8 -0
  77. package/script/deps/deno.land/std@0.196.0/assert/assert_instance_of.js +42 -0
  78. package/script/deps/deno.land/std@0.196.0/assert/assert_is_error.d.ts +7 -0
  79. package/script/deps/deno.land/std@0.196.0/assert/assert_is_error.js +30 -0
  80. package/script/deps/deno.land/std@0.196.0/assert/assert_match.d.ts +5 -0
  81. package/script/deps/deno.land/std@0.196.0/assert/assert_match.js +17 -0
  82. package/script/deps/deno.land/std@0.196.0/assert/assert_not_equals.d.ts +14 -0
  83. package/script/deps/deno.land/std@0.196.0/assert/assert_not_equals.js +41 -0
  84. package/script/deps/deno.land/std@0.196.0/assert/assert_not_instance_of.d.ts +5 -0
  85. package/script/deps/deno.land/std@0.196.0/assert/assert_not_instance_of.js +18 -0
  86. package/script/deps/deno.land/std@0.196.0/assert/assert_not_match.d.ts +5 -0
  87. package/script/deps/deno.land/std@0.196.0/assert/assert_not_match.js +18 -0
  88. package/script/deps/deno.land/std@0.196.0/assert/assert_not_strict_equals.d.ts +11 -0
  89. package/script/deps/deno.land/std@0.196.0/assert/assert_not_strict_equals.js +24 -0
  90. package/script/deps/deno.land/std@0.196.0/assert/assert_object_match.d.ts +5 -0
  91. package/script/deps/deno.land/std@0.196.0/assert/assert_object_match.js +82 -0
  92. package/script/deps/deno.land/std@0.196.0/assert/assert_rejects.d.ts +64 -0
  93. package/script/deps/deno.land/std@0.196.0/assert/assert_rejects.js +54 -0
  94. package/script/deps/deno.land/std@0.196.0/assert/assert_strict_equals.d.ts +23 -0
  95. package/script/deps/deno.land/std@0.196.0/assert/assert_strict_equals.js +64 -0
  96. package/script/deps/deno.land/std@0.196.0/assert/assert_string_includes.d.ts +5 -0
  97. package/script/deps/deno.land/std@0.196.0/assert/assert_string_includes.js +17 -0
  98. package/script/deps/deno.land/std@0.196.0/assert/assert_throws.d.ts +54 -0
  99. package/script/deps/deno.land/std@0.196.0/assert/assert_throws.js +48 -0
  100. package/script/deps/deno.land/std@0.196.0/assert/assertion_error.d.ts +4 -0
  101. package/script/deps/deno.land/std@0.196.0/assert/assertion_error.js +16 -0
  102. package/script/deps/deno.land/std@0.196.0/assert/equal.d.ts +6 -0
  103. package/script/deps/deno.land/std@0.196.0/assert/equal.js +106 -0
  104. package/script/deps/deno.land/std@0.196.0/assert/fail.d.ts +4 -0
  105. package/script/deps/deno.land/std@0.196.0/assert/fail.js +13 -0
  106. package/script/deps/deno.land/std@0.196.0/assert/mod.d.ts +32 -0
  107. package/script/deps/deno.land/std@0.196.0/assert/mod.js +49 -0
  108. package/script/deps/deno.land/std@0.196.0/assert/unimplemented.d.ts +2 -0
  109. package/script/deps/deno.land/std@0.196.0/assert/unimplemented.js +11 -0
  110. package/script/deps/deno.land/std@0.196.0/assert/unreachable.d.ts +2 -0
  111. package/script/deps/deno.land/std@0.196.0/assert/unreachable.js +10 -0
  112. package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.js +2 -2
  113. package/{esm/deps/deno.land/std@0.190.0 → script/deps/deno.land/std@0.196.0}/testing/asserts.d.ts +204 -159
  114. package/script/deps/deno.land/std@0.196.0/testing/asserts.js +333 -0
  115. package/script/deps.d.ts +2 -2
  116. package/script/deps.js +2 -2
  117. package/script/tl/1_tl_object.js +1 -1
  118. package/esm/deps/deno.land/std@0.190.0/testing/asserts.js +0 -633
  119. package/script/deps/deno.land/std@0.190.0/testing/asserts.js +0 -659
  120. /package/esm/deps/deno.land/{std@0.190.0/testing/_diff.d.ts → std@0.196.0/_util/diff.d.ts} +0 -0
  121. /package/esm/deps/deno.land/{std@0.190.0/testing/_diff.js → std@0.196.0/_util/diff.js} +0 -0
  122. /package/esm/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.d.ts +0 -0
  123. /package/esm/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.js +0 -0
  124. /package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.d.ts +0 -0
  125. /package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.js +0 -0
  126. /package/esm/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.d.ts +0 -0
  127. /package/script/deps/deno.land/{std@0.190.0/testing/_diff.d.ts → std@0.196.0/_util/diff.d.ts} +0 -0
  128. /package/script/deps/deno.land/{std@0.190.0/testing/_diff.js → std@0.196.0/_util/diff.js} +0 -0
  129. /package/script/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.d.ts +0 -0
  130. /package/script/deps/deno.land/{std@0.190.0/testing → std@0.196.0/assert}/_format.js +0 -0
  131. /package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.d.ts +0 -0
  132. /package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/encoding/base64.js +0 -0
  133. /package/script/deps/deno.land/{std@0.190.0 → std@0.196.0}/fmt/colors.d.ts +0 -0
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertInstanceOf = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ /**
7
+ * Make an assertion that `obj` is an instance of `type`.
8
+ * If not then throw.
9
+ */
10
+ function assertInstanceOf(actual, expectedType, msg = "") {
11
+ if (actual instanceof expectedType)
12
+ return;
13
+ const msgSuffix = msg ? `: ${msg}` : ".";
14
+ const expectedTypeStr = expectedType.name;
15
+ let actualTypeStr = "";
16
+ if (actual === null) {
17
+ actualTypeStr = "null";
18
+ }
19
+ else if (actual === undefined) {
20
+ actualTypeStr = "undefined";
21
+ }
22
+ else if (typeof actual === "object") {
23
+ actualTypeStr = actual.constructor?.name ?? "Object";
24
+ }
25
+ else {
26
+ actualTypeStr = typeof actual;
27
+ }
28
+ if (expectedTypeStr == actualTypeStr) {
29
+ msg =
30
+ `Expected object to be an instance of "${expectedTypeStr}"${msgSuffix}`;
31
+ }
32
+ else if (actualTypeStr == "function") {
33
+ msg =
34
+ `Expected object to be an instance of "${expectedTypeStr}" but was not an instanced object${msgSuffix}`;
35
+ }
36
+ else {
37
+ msg =
38
+ `Expected object to be an instance of "${expectedTypeStr}" but was "${actualTypeStr}"${msgSuffix}`;
39
+ }
40
+ throw new assertion_error_js_1.AssertionError(msg);
41
+ }
42
+ exports.assertInstanceOf = assertInstanceOf;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Make an assertion that `error` is an `Error`.
3
+ * If not then an error will be thrown.
4
+ * An error class and a string that should be included in the
5
+ * error message can also be asserted.
6
+ */
7
+ export declare function assertIsError<E extends Error = Error>(error: unknown, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): asserts error is E;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertIsError = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ const colors_js_1 = require("../fmt/colors.js");
7
+ /**
8
+ * Make an assertion that `error` is an `Error`.
9
+ * If not then an error will be thrown.
10
+ * An error class and a string that should be included in the
11
+ * error message can also be asserted.
12
+ */
13
+ function assertIsError(error,
14
+ // deno-lint-ignore no-explicit-any
15
+ ErrorClass, msgIncludes, msg) {
16
+ const msgSuffix = msg ? `: ${msg}` : ".";
17
+ if (error instanceof Error === false) {
18
+ throw new assertion_error_js_1.AssertionError(`Expected "error" to be an Error object${msgSuffix}}`);
19
+ }
20
+ if (ErrorClass && !(error instanceof ErrorClass)) {
21
+ msg = `Expected error to be instance of "${ErrorClass.name}", but was "${typeof error === "object" ? error?.constructor?.name : "[not an object]"}"${msgSuffix}`;
22
+ throw new assertion_error_js_1.AssertionError(msg);
23
+ }
24
+ if (msgIncludes && (!(error instanceof Error) ||
25
+ !(0, colors_js_1.stripColor)(error.message).includes((0, colors_js_1.stripColor)(msgIncludes)))) {
26
+ msg = `Expected error message to include "${msgIncludes}", but got "${error instanceof Error ? error.message : "[not an Error]"}"${msgSuffix}`;
27
+ throw new assertion_error_js_1.AssertionError(msg);
28
+ }
29
+ }
30
+ exports.assertIsError = assertIsError;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` match RegExp `expected`. If not
3
+ * then throw.
4
+ */
5
+ export declare function assertMatch(actual: string, expected: RegExp, msg?: string): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertMatch = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ /**
7
+ * Make an assertion that `actual` match RegExp `expected`. If not
8
+ * then throw.
9
+ */
10
+ function assertMatch(actual, expected, msg) {
11
+ if (!expected.test(actual)) {
12
+ const msgSuffix = msg ? `: ${msg}` : ".";
13
+ msg = `Expected actual: "${actual}" to match: "${expected}"${msgSuffix}`;
14
+ throw new assertion_error_js_1.AssertionError(msg);
15
+ }
16
+ }
17
+ exports.assertMatch = assertMatch;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Make an assertion that `actual` and `expected` are not equal, deeply.
3
+ * If not then throw.
4
+ *
5
+ * Type parameter can be specified to ensure values under comparison have the same type.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { assertNotEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_not_equals.ts";
10
+ *
11
+ * assertNotEquals<number>(1, 2)
12
+ * ```
13
+ */
14
+ export declare function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertNotEquals = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const equal_js_1 = require("./equal.js");
6
+ const assertion_error_js_1 = require("./assertion_error.js");
7
+ /**
8
+ * Make an assertion that `actual` and `expected` are not equal, deeply.
9
+ * If not then throw.
10
+ *
11
+ * Type parameter can be specified to ensure values under comparison have the same type.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { assertNotEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_not_equals.ts";
16
+ *
17
+ * assertNotEquals<number>(1, 2)
18
+ * ```
19
+ */
20
+ function assertNotEquals(actual, expected, msg) {
21
+ if (!(0, equal_js_1.equal)(actual, expected)) {
22
+ return;
23
+ }
24
+ let actualString;
25
+ let expectedString;
26
+ try {
27
+ actualString = String(actual);
28
+ }
29
+ catch {
30
+ actualString = "[Cannot display]";
31
+ }
32
+ try {
33
+ expectedString = String(expected);
34
+ }
35
+ catch {
36
+ expectedString = "[Cannot display]";
37
+ }
38
+ const msgSuffix = msg ? `: ${msg}` : ".";
39
+ throw new assertion_error_js_1.AssertionError(`Expected actual: ${actualString} not to be: ${expectedString}${msgSuffix}`);
40
+ }
41
+ exports.assertNotEquals = assertNotEquals;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `obj` is not an instance of `type`.
3
+ * If so, then throw.
4
+ */
5
+ export declare function assertNotInstanceOf<A, T>(actual: A, unexpectedType: new (...args: any[]) => T, msg?: string): asserts actual is Exclude<A, T>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertNotInstanceOf = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assert_false_js_1 = require("./assert_false.js");
6
+ /**
7
+ * Make an assertion that `obj` is not an instance of `type`.
8
+ * If so, then throw.
9
+ */
10
+ function assertNotInstanceOf(actual,
11
+ // deno-lint-ignore no-explicit-any
12
+ unexpectedType, msg) {
13
+ const msgSuffix = msg ? `: ${msg}` : ".";
14
+ msg =
15
+ `Expected object to not be an instance of "${typeof unexpectedType}"${msgSuffix}`;
16
+ (0, assert_false_js_1.assertFalse)(actual instanceof unexpectedType, msg);
17
+ }
18
+ exports.assertNotInstanceOf = assertNotInstanceOf;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` not match RegExp `expected`. If match
3
+ * then throw.
4
+ */
5
+ export declare function assertNotMatch(actual: string, expected: RegExp, msg?: string): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertNotMatch = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ /**
7
+ * Make an assertion that `actual` not match RegExp `expected`. If match
8
+ * then throw.
9
+ */
10
+ function assertNotMatch(actual, expected, msg) {
11
+ if (expected.test(actual)) {
12
+ const msgSuffix = msg ? `: ${msg}` : ".";
13
+ msg =
14
+ `Expected actual: "${actual}" to not match: "${expected}"${msgSuffix}`;
15
+ throw new assertion_error_js_1.AssertionError(msg);
16
+ }
17
+ }
18
+ exports.assertNotMatch = assertNotMatch;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Make an assertion that `actual` and `expected` are not strictly equal.
3
+ * If the values are strictly equal then throw.
4
+ *
5
+ * ```ts
6
+ * import { assertNotStrictEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_not_strict_equals.ts";
7
+ *
8
+ * assertNotStrictEquals(1, 1)
9
+ * ```
10
+ */
11
+ export declare function assertNotStrictEquals<T>(actual: T, expected: T, msg?: string): void;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertNotStrictEquals = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ const _format_js_1 = require("./_format.js");
7
+ /**
8
+ * Make an assertion that `actual` and `expected` are not strictly equal.
9
+ * If the values are strictly equal then throw.
10
+ *
11
+ * ```ts
12
+ * import { assertNotStrictEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_not_strict_equals.ts";
13
+ *
14
+ * assertNotStrictEquals(1, 1)
15
+ * ```
16
+ */
17
+ function assertNotStrictEquals(actual, expected, msg) {
18
+ if (!Object.is(actual, expected)) {
19
+ return;
20
+ }
21
+ const msgSuffix = msg ? `: ${msg}` : ".";
22
+ throw new assertion_error_js_1.AssertionError(`Expected "actual" to be strictly unequal to: ${(0, _format_js_1.format)(actual)}${msgSuffix}\n`);
23
+ }
24
+ exports.assertNotStrictEquals = assertNotStrictEquals;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Make an assertion that `actual` object is a subset of `expected` object, deeply.
3
+ * If not, then throw.
4
+ */
5
+ export declare function assertObjectMatch(actual: Record<PropertyKey, any>, expected: Record<PropertyKey, unknown>, msg?: string): void;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertObjectMatch = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assert_equals_js_1 = require("./assert_equals.js");
6
+ /**
7
+ * Make an assertion that `actual` object is a subset of `expected` object, deeply.
8
+ * If not, then throw.
9
+ */
10
+ function assertObjectMatch(
11
+ // deno-lint-ignore no-explicit-any
12
+ actual, expected, msg) {
13
+ function filter(a, b) {
14
+ const seen = new WeakMap();
15
+ return fn(a, b);
16
+ function fn(a, b) {
17
+ // Prevent infinite loop with circular references with same filter
18
+ if ((seen.has(a)) && (seen.get(a) === b)) {
19
+ return a;
20
+ }
21
+ try {
22
+ seen.set(a, b);
23
+ }
24
+ catch (err) {
25
+ if (err instanceof TypeError) {
26
+ throw new TypeError(`Cannot assertObjectMatch ${a === null ? null : `type ${typeof a}`}`);
27
+ }
28
+ else
29
+ throw err;
30
+ }
31
+ // Filter keys and symbols which are present in both actual and expected
32
+ const filtered = {};
33
+ const entries = [
34
+ ...Object.getOwnPropertyNames(a),
35
+ ...Object.getOwnPropertySymbols(a),
36
+ ]
37
+ .filter((key) => key in b)
38
+ .map((key) => [key, a[key]]);
39
+ for (const [key, value] of entries) {
40
+ // On array references, build a filtered array and filter nested objects inside
41
+ if (Array.isArray(value)) {
42
+ const subset = b[key];
43
+ if (Array.isArray(subset)) {
44
+ filtered[key] = fn({ ...value }, { ...subset });
45
+ continue;
46
+ }
47
+ } // On regexp references, keep value as it to avoid loosing pattern and flags
48
+ else if (value instanceof RegExp) {
49
+ filtered[key] = value;
50
+ continue;
51
+ } // On nested objects references, build a filtered object recursively
52
+ else if (typeof value === "object" && value !== null) {
53
+ const subset = b[key];
54
+ if ((typeof subset === "object") && (subset)) {
55
+ // When both operands are maps, build a filtered map with common keys and filter nested objects inside
56
+ if ((value instanceof Map) && (subset instanceof Map)) {
57
+ filtered[key] = new Map([...value].filter(([k]) => subset.has(k)).map(([k, v]) => [k, typeof v === "object" ? fn(v, subset.get(k)) : v]));
58
+ continue;
59
+ }
60
+ // When both operands are set, build a filtered set with common values
61
+ if ((value instanceof Set) && (subset instanceof Set)) {
62
+ filtered[key] = new Set([...value].filter((v) => subset.has(v)));
63
+ continue;
64
+ }
65
+ filtered[key] = fn(value, subset);
66
+ continue;
67
+ }
68
+ }
69
+ filtered[key] = value;
70
+ }
71
+ return filtered;
72
+ }
73
+ }
74
+ return (0, assert_equals_js_1.assertEquals)(
75
+ // get the intersection of "actual" and "expected"
76
+ // side effect: all the instances' constructor field is "Object" now.
77
+ filter(actual, expected),
78
+ // set (nested) instances' constructor field to be "Object" without changing expected value.
79
+ // see https://github.com/denoland/deno_std/pull/1419
80
+ filter(expected, expected), msg);
81
+ }
82
+ exports.assertObjectMatch = assertObjectMatch;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Executes a function which returns a promise, expecting it to reject.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { assertRejects } from "https://deno.land/std@$STD_VERSION/assert/assert_rejects.ts";
7
+ *
8
+ * Deno.test("doesThrow", async function () {
9
+ * await assertRejects(
10
+ * async () => {
11
+ * throw new TypeError("hello world!");
12
+ * },
13
+ * );
14
+ * await assertRejects(
15
+ * async () => {
16
+ * return Promise.reject(new Error());
17
+ * },
18
+ * );
19
+ * });
20
+ *
21
+ * // This test will not pass.
22
+ * Deno.test("fails", async function () {
23
+ * await assertRejects(
24
+ * async () => {
25
+ * console.log("Hello world");
26
+ * },
27
+ * );
28
+ * });
29
+ * ```
30
+ */
31
+ export declare function assertRejects(fn: () => PromiseLike<unknown>, msg?: string): Promise<unknown>;
32
+ /**
33
+ * Executes a function which returns a promise, expecting it to reject.
34
+ * If it does not, then it throws. An error class and a string that should be
35
+ * included in the error message can also be asserted.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { assertRejects } from "https://deno.land/std@$STD_VERSION/assert/assert_rejects.ts";
40
+ *
41
+ * Deno.test("doesThrow", async function () {
42
+ * await assertRejects(async () => {
43
+ * throw new TypeError("hello world!");
44
+ * }, TypeError);
45
+ * await assertRejects(
46
+ * async () => {
47
+ * throw new TypeError("hello world!");
48
+ * },
49
+ * TypeError,
50
+ * "hello",
51
+ * );
52
+ * });
53
+ *
54
+ * // This test will not pass.
55
+ * Deno.test("fails", async function () {
56
+ * await assertRejects(
57
+ * async () => {
58
+ * console.log("Hello world");
59
+ * },
60
+ * );
61
+ * });
62
+ * ```
63
+ */
64
+ export declare function assertRejects<E extends Error = Error>(fn: () => PromiseLike<unknown>, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): Promise<E>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertRejects = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ const assert_is_error_js_1 = require("./assert_is_error.js");
7
+ async function assertRejects(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
8
+ // deno-lint-ignore no-explicit-any
9
+ let ErrorClass = undefined;
10
+ let msgIncludes = undefined;
11
+ let err;
12
+ if (typeof errorClassOrMsg !== "string") {
13
+ if (errorClassOrMsg === undefined ||
14
+ errorClassOrMsg.prototype instanceof Error ||
15
+ errorClassOrMsg.prototype === Error.prototype) {
16
+ // deno-lint-ignore no-explicit-any
17
+ ErrorClass = errorClassOrMsg;
18
+ msgIncludes = msgIncludesOrMsg;
19
+ }
20
+ }
21
+ else {
22
+ msg = errorClassOrMsg;
23
+ }
24
+ let doesThrow = false;
25
+ let isPromiseReturned = false;
26
+ const msgSuffix = msg ? `: ${msg}` : ".";
27
+ try {
28
+ const possiblePromise = fn();
29
+ if (possiblePromise &&
30
+ typeof possiblePromise === "object" &&
31
+ typeof possiblePromise.then === "function") {
32
+ isPromiseReturned = true;
33
+ await possiblePromise;
34
+ }
35
+ }
36
+ catch (error) {
37
+ if (!isPromiseReturned) {
38
+ throw new assertion_error_js_1.AssertionError(`Function throws when expected to reject${msgSuffix}`);
39
+ }
40
+ if (ErrorClass) {
41
+ if (error instanceof Error === false) {
42
+ throw new assertion_error_js_1.AssertionError(`A non-Error object was rejected${msgSuffix}`);
43
+ }
44
+ (0, assert_is_error_js_1.assertIsError)(error, ErrorClass, msgIncludes, msg);
45
+ }
46
+ err = error;
47
+ doesThrow = true;
48
+ }
49
+ if (!doesThrow) {
50
+ throw new assertion_error_js_1.AssertionError(`Expected function to reject${msgSuffix}`);
51
+ }
52
+ return err;
53
+ }
54
+ exports.assertRejects = assertRejects;
@@ -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,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertStrictEquals = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const _format_js_1 = require("./_format.js");
6
+ const assertion_error_js_1 = require("./assertion_error.js");
7
+ const diff_js_1 = require("../_util/diff.js");
8
+ const _constants_js_1 = require("./_constants.js");
9
+ const colors_js_1 = require("../fmt/colors.js");
10
+ /**
11
+ * Make an assertion that `actual` and `expected` are strictly equal. If
12
+ * not then throw.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { assertStrictEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_strict_equals.ts";
17
+ *
18
+ * Deno.test("isStrictlyEqual", function (): void {
19
+ * const a = {};
20
+ * const b = a;
21
+ * assertStrictEquals(a, b);
22
+ * });
23
+ *
24
+ * // This test fails
25
+ * Deno.test("isNotStrictlyEqual", function (): void {
26
+ * const a = {};
27
+ * const b = {};
28
+ * assertStrictEquals(a, b);
29
+ * });
30
+ * ```
31
+ */
32
+ function assertStrictEquals(actual, expected, msg) {
33
+ if (Object.is(actual, expected)) {
34
+ return;
35
+ }
36
+ const msgSuffix = msg ? `: ${msg}` : ".";
37
+ let message;
38
+ const actualString = (0, _format_js_1.format)(actual);
39
+ const expectedString = (0, _format_js_1.format)(expected);
40
+ if (actualString === expectedString) {
41
+ const withOffset = actualString
42
+ .split("\n")
43
+ .map((l) => ` ${l}`)
44
+ .join("\n");
45
+ message =
46
+ `Values have the same structure but are not reference-equal${msgSuffix}\n\n${(0, colors_js_1.red)(withOffset)}\n`;
47
+ }
48
+ else {
49
+ try {
50
+ const stringDiff = (typeof actual === "string") &&
51
+ (typeof expected === "string");
52
+ const diffResult = stringDiff
53
+ ? (0, diff_js_1.diffstr)(actual, expected)
54
+ : (0, diff_js_1.diff)(actualString.split("\n"), expectedString.split("\n"));
55
+ const diffMsg = (0, diff_js_1.buildMessage)(diffResult, { stringDiff }).join("\n");
56
+ message = `Values are not strictly equal${msgSuffix}\n${diffMsg}`;
57
+ }
58
+ catch {
59
+ message = `\n${(0, colors_js_1.red)(_constants_js_1.CAN_NOT_DISPLAY)} + \n\n`;
60
+ }
61
+ }
62
+ throw new assertion_error_js_1.AssertionError(message);
63
+ }
64
+ exports.assertStrictEquals = assertStrictEquals;
@@ -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,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertStringIncludes = void 0;
4
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
+ const assertion_error_js_1 = require("./assertion_error.js");
6
+ /**
7
+ * Make an assertion that actual includes expected. If not
8
+ * then throw.
9
+ */
10
+ function assertStringIncludes(actual, expected, msg) {
11
+ if (!actual.includes(expected)) {
12
+ const msgSuffix = msg ? `: ${msg}` : ".";
13
+ msg = `Expected actual: "${actual}" to contain: "${expected}"${msgSuffix}`;
14
+ throw new assertion_error_js_1.AssertionError(msg);
15
+ }
16
+ }
17
+ exports.assertStringIncludes = assertStringIncludes;
@@ -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;