@kerebron/test-utils 0.4.27 → 0.4.29

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 (182) hide show
  1. package/esm/_dnt.shims.d.ts +2 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/_dnt.shims.js +58 -0
  4. package/esm/_dnt.shims.js.map +1 -0
  5. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts +29 -0
  6. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js +47 -0
  8. package/esm/deps/jsr.io/@std/assert/1.0.16/almost_equals.js.map +1 -0
  9. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts +24 -0
  10. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js +47 -0
  12. package/esm/deps/jsr.io/@std/assert/1.0.16/array_includes.js.map +1 -0
  13. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts +16 -0
  14. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js +23 -0
  16. package/esm/deps/jsr.io/@std/assert/1.0.16/assert.js.map +1 -0
  17. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +26 -0
  18. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +31 -0
  20. package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js.map +1 -0
  21. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts +17 -0
  22. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js +187 -0
  24. package/esm/deps/jsr.io/@std/assert/1.0.16/equal.js.map +1 -0
  25. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts +35 -0
  26. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js +60 -0
  28. package/esm/deps/jsr.io/@std/assert/1.0.16/equals.js.map +1 -0
  29. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts +18 -0
  30. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js +28 -0
  32. package/esm/deps/jsr.io/@std/assert/1.0.16/exists.js.map +1 -0
  33. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts +15 -0
  34. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js +21 -0
  36. package/esm/deps/jsr.io/@std/assert/1.0.16/fail.js.map +1 -0
  37. package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts +18 -0
  38. package/esm/deps/jsr.io/@std/assert/1.0.16/false.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/assert/1.0.16/false.js +23 -0
  40. package/esm/deps/jsr.io/@std/assert/1.0.16/false.js.map +1 -0
  41. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts +20 -0
  42. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.d.ts.map +1 -0
  43. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js +30 -0
  44. package/esm/deps/jsr.io/@std/assert/1.0.16/greater.js.map +1 -0
  45. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts +20 -0
  46. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js +30 -0
  48. package/esm/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.js.map +1 -0
  49. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +23 -0
  50. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +53 -0
  52. package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js.map +1 -0
  53. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts +25 -0
  54. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.d.ts.map +1 -0
  55. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js +54 -0
  56. package/esm/deps/jsr.io/@std/assert/1.0.16/is_error.js.map +1 -0
  57. package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts +19 -0
  58. package/esm/deps/jsr.io/@std/assert/1.0.16/less.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@std/assert/1.0.16/less.js +29 -0
  60. package/esm/deps/jsr.io/@std/assert/1.0.16/less.js.map +1 -0
  61. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts +20 -0
  62. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js +30 -0
  64. package/esm/deps/jsr.io/@std/assert/1.0.16/less_or_equal.js.map +1 -0
  65. package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts +18 -0
  66. package/esm/deps/jsr.io/@std/assert/1.0.16/match.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@std/assert/1.0.16/match.js +27 -0
  68. package/esm/deps/jsr.io/@std/assert/1.0.16/match.js.map +1 -0
  69. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts +44 -0
  70. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.d.ts.map +1 -0
  71. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js +46 -0
  72. package/esm/deps/jsr.io/@std/assert/1.0.16/mod.js.map +1 -0
  73. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts +21 -0
  74. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js +34 -0
  76. package/esm/deps/jsr.io/@std/assert/1.0.16/not_equals.js.map +1 -0
  77. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts +20 -0
  78. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.d.ts.map +1 -0
  79. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js +30 -0
  80. package/esm/deps/jsr.io/@std/assert/1.0.16/not_instance_of.js.map +1 -0
  81. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts +18 -0
  82. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.d.ts.map +1 -0
  83. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js +27 -0
  84. package/esm/deps/jsr.io/@std/assert/1.0.16/not_match.js.map +1 -0
  85. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts +23 -0
  86. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js +33 -0
  88. package/esm/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.js.map +1 -0
  89. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts +29 -0
  90. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.d.ts.map +1 -0
  91. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js +168 -0
  92. package/esm/deps/jsr.io/@std/assert/1.0.16/object_match.js.map +1 -0
  93. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts +42 -0
  94. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.d.ts.map +1 -0
  95. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js +54 -0
  96. package/esm/deps/jsr.io/@std/assert/1.0.16/rejects.js.map +1 -0
  97. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts +24 -0
  98. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.d.ts.map +1 -0
  99. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js +59 -0
  100. package/esm/deps/jsr.io/@std/assert/1.0.16/strict_equals.js.map +1 -0
  101. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts +18 -0
  102. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.d.ts.map +1 -0
  103. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js +27 -0
  104. package/esm/deps/jsr.io/@std/assert/1.0.16/string_includes.js.map +1 -0
  105. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts +45 -0
  106. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.d.ts.map +1 -0
  107. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js +45 -0
  108. package/esm/deps/jsr.io/@std/assert/1.0.16/throws.js.map +1 -0
  109. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts +15 -0
  110. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.d.ts.map +1 -0
  111. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js +21 -0
  112. package/esm/deps/jsr.io/@std/assert/1.0.16/unimplemented.js.map +1 -0
  113. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts +15 -0
  114. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.d.ts.map +1 -0
  115. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js +21 -0
  116. package/esm/deps/jsr.io/@std/assert/1.0.16/unreachable.js.map +1 -0
  117. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts +80 -0
  118. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +1 -0
  119. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js +117 -0
  120. package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.js.map +1 -0
  121. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts +140 -0
  122. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +1 -0
  123. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js +277 -0
  124. package/esm/deps/jsr.io/@std/internal/1.0.12/diff.js.map +1 -0
  125. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts +99 -0
  126. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +1 -0
  127. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js +183 -0
  128. package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.js.map +1 -0
  129. package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts +29 -0
  130. package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +1 -0
  131. package/esm/deps/jsr.io/@std/internal/1.0.12/format.js +71 -0
  132. package/esm/deps/jsr.io/@std/internal/1.0.12/format.js.map +1 -0
  133. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts +159 -0
  134. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +1 -0
  135. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js +208 -0
  136. package/esm/deps/jsr.io/@std/internal/1.0.12/styles.js.map +1 -0
  137. package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts +25 -0
  138. package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +1 -0
  139. package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +4 -0
  140. package/esm/deps/jsr.io/@std/internal/1.0.12/types.js.map +1 -0
  141. package/esm/package.json +3 -0
  142. package/esm/test-utils.d.ts +3 -0
  143. package/esm/test-utils.d.ts.map +1 -0
  144. package/esm/test-utils.js +12 -0
  145. package/esm/test-utils.js.map +1 -0
  146. package/package.json +5 -2
  147. package/src/_dnt.shims.ts +60 -0
  148. package/src/deps/jsr.io/@std/assert/1.0.16/almost_equals.ts +55 -0
  149. package/src/deps/jsr.io/@std/assert/1.0.16/array_includes.ts +57 -0
  150. package/src/deps/jsr.io/@std/assert/1.0.16/assert.ts +23 -0
  151. package/src/deps/jsr.io/@std/assert/1.0.16/assertion_error.ts +31 -0
  152. package/src/deps/jsr.io/@std/assert/1.0.16/equal.ts +218 -0
  153. package/src/deps/jsr.io/@std/assert/1.0.16/equals.ts +66 -0
  154. package/src/deps/jsr.io/@std/assert/1.0.16/exists.ts +31 -0
  155. package/src/deps/jsr.io/@std/assert/1.0.16/fail.ts +21 -0
  156. package/src/deps/jsr.io/@std/assert/1.0.16/false.ts +26 -0
  157. package/src/deps/jsr.io/@std/assert/1.0.16/greater.ts +30 -0
  158. package/src/deps/jsr.io/@std/assert/1.0.16/greater_or_equal.ts +36 -0
  159. package/src/deps/jsr.io/@std/assert/1.0.16/instance_of.ts +64 -0
  160. package/src/deps/jsr.io/@std/assert/1.0.16/is_error.ts +65 -0
  161. package/src/deps/jsr.io/@std/assert/1.0.16/less.ts +29 -0
  162. package/src/deps/jsr.io/@std/assert/1.0.16/less_or_equal.ts +36 -0
  163. package/src/deps/jsr.io/@std/assert/1.0.16/match.ts +30 -0
  164. package/src/deps/jsr.io/@std/assert/1.0.16/mod.ts +47 -0
  165. package/src/deps/jsr.io/@std/assert/1.0.16/not_equals.ts +37 -0
  166. package/src/deps/jsr.io/@std/assert/1.0.16/not_instance_of.ts +33 -0
  167. package/src/deps/jsr.io/@std/assert/1.0.16/not_match.ts +30 -0
  168. package/src/deps/jsr.io/@std/assert/1.0.16/not_strict_equals.ts +42 -0
  169. package/src/deps/jsr.io/@std/assert/1.0.16/object_match.ts +214 -0
  170. package/src/deps/jsr.io/@std/assert/1.0.16/rejects.ts +123 -0
  171. package/src/deps/jsr.io/@std/assert/1.0.16/strict_equals.ts +68 -0
  172. package/src/deps/jsr.io/@std/assert/1.0.16/string_includes.ts +30 -0
  173. package/src/deps/jsr.io/@std/assert/1.0.16/throws.ts +111 -0
  174. package/src/deps/jsr.io/@std/assert/1.0.16/unimplemented.ts +21 -0
  175. package/src/deps/jsr.io/@std/assert/1.0.16/unreachable.ts +21 -0
  176. package/src/deps/jsr.io/@std/internal/1.0.12/build_message.ts +147 -0
  177. package/src/deps/jsr.io/@std/internal/1.0.12/diff.ts +317 -0
  178. package/src/deps/jsr.io/@std/internal/1.0.12/diff_str.ts +208 -0
  179. package/src/deps/jsr.io/@std/internal/1.0.12/format.ts +89 -0
  180. package/src/deps/jsr.io/@std/internal/1.0.12/styles.ts +233 -0
  181. package/src/deps/jsr.io/@std/internal/1.0.12/types.ts +30 -0
  182. package/src/test-utils.ts +12 -0
@@ -0,0 +1,89 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /** An inspect function conforming to the shape of `Deno.inspect` and `node:util`'s `inspect` */
5
+ import * as dntShim from "../../../../../_dnt.shims.js";
6
+
7
+ export type InspectFn = (
8
+ v: unknown,
9
+ options: {
10
+ depth: number;
11
+ sorted: boolean;
12
+ trailingComma: boolean;
13
+ compact: boolean;
14
+ iterableLimit: number;
15
+ getters: boolean;
16
+ strAbbreviateSize: number;
17
+ },
18
+ ) => string;
19
+
20
+ /**
21
+ * Converts the input into a string. Objects, Sets and Maps are sorted so as to
22
+ * make tests less flaky.
23
+ *
24
+ * @param v Value to be formatted
25
+ *
26
+ * @returns The formatted string
27
+ *
28
+ * @example Usage
29
+ * ```ts
30
+ * import { format } from "@std/internal/format";
31
+ * import { assertEquals } from "@std/assert";
32
+ *
33
+ * assertEquals(format({ a: 1, b: 2 }), "{\n a: 1,\n b: 2,\n}");
34
+ * assertEquals(format(new Set([1, 2])), "Set(2) {\n 1,\n 2,\n}");
35
+ * assertEquals(format(new Map([[1, 2]])), "Map(1) {\n 1 => 2,\n}");
36
+ * ```
37
+ */
38
+ export function format(v: unknown): string {
39
+ // deno-lint-ignore no-explicit-any
40
+ const { Deno, process } = dntShim.dntGlobalThis as any;
41
+
42
+ const inspect: InspectFn | undefined = Deno?.inspect ??
43
+ process?.getBuiltinModule?.("node:util")?.inspect;
44
+
45
+ return typeof inspect === "function"
46
+ ? inspect(v, {
47
+ depth: Infinity,
48
+ sorted: true,
49
+ trailingComma: true,
50
+ compact: false,
51
+ iterableLimit: Infinity,
52
+ // getters should be true in assertEquals.
53
+ getters: true,
54
+ strAbbreviateSize: Infinity,
55
+ })
56
+ : basicInspect(v);
57
+ }
58
+
59
+ const formatters: ((v: unknown) => string | undefined)[] = [
60
+ (v) => {
61
+ if (typeof v === "undefined") return "undefined";
62
+ if (typeof v === "bigint") return `${v}n`;
63
+
64
+ if (
65
+ typeof v === "string" ||
66
+ typeof v === "number" ||
67
+ typeof v === "boolean" ||
68
+ v === null ||
69
+ Array.isArray(v) ||
70
+ [null, Object.prototype].includes(Object.getPrototypeOf(v))
71
+ ) {
72
+ return JSON.stringify(v, null, 2);
73
+ }
74
+ },
75
+ (v) => String(v),
76
+ (v) => Object.prototype.toString.call(v),
77
+ ];
78
+
79
+ // for environments lacking both `Deno.inspect` and `process.inspect`
80
+ function basicInspect(v: unknown): string {
81
+ for (const fmt of formatters) {
82
+ try {
83
+ const result = fmt(v);
84
+ if (typeof result === "string") return result;
85
+ } catch { /* try the next one */ }
86
+ }
87
+
88
+ return "[[Unable to format value]]";
89
+ }
@@ -0,0 +1,233 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ // A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
4
+ // on npm.
5
+
6
+ // This code is vendored from `fmt/colors.ts`.
7
+
8
+ // deno-lint-ignore no-explicit-any
9
+ import * as dntShim from "../../../../../_dnt.shims.js";
10
+
11
+ const { Deno } = dntShim.dntGlobalThis as any;
12
+ const noColor = typeof Deno?.noColor === "boolean"
13
+ ? Deno.noColor as boolean
14
+ : false;
15
+
16
+ interface Code {
17
+ open: string;
18
+ close: string;
19
+ regexp: RegExp;
20
+ }
21
+
22
+ const enabled = !noColor;
23
+
24
+ function code(open: number[], close: number): Code {
25
+ return {
26
+ open: `\x1b[${open.join(";")}m`,
27
+ close: `\x1b[${close}m`,
28
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
29
+ };
30
+ }
31
+
32
+ function run(str: string, code: Code): string {
33
+ return enabled
34
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
35
+ : str;
36
+ }
37
+
38
+ /**
39
+ * Sets the style of text to be printed to bold.
40
+ *
41
+ * Disable by setting the `NO_COLOR` environmental variable.
42
+ *
43
+ * @param str Text to make bold
44
+ *
45
+ * @returns Bold text for printing
46
+ *
47
+ * @example Usage
48
+ * ```ts no-assert
49
+ * import { bold } from "@std/internal/styles";
50
+ *
51
+ * console.log(bold("Hello, world!")); // Prints "Hello, world!" in bold
52
+ * ```
53
+ */
54
+ export function bold(str: string): string {
55
+ return run(str, code([1], 22));
56
+ }
57
+
58
+ /**
59
+ * Sets the color of text to be printed to red.
60
+ *
61
+ * Disable by setting the `NO_COLOR` environmental variable.
62
+ *
63
+ * @param str Text to make red
64
+ *
65
+ * @returns Red text for printing
66
+ *
67
+ * @example Usage
68
+ * ```ts no-assert
69
+ * import { red } from "@std/internal/styles";
70
+ *
71
+ * console.log(red("Hello, world!")); // Prints "Hello, world!" in red
72
+ * ```
73
+ */
74
+ export function red(str: string): string {
75
+ return run(str, code([31], 39));
76
+ }
77
+
78
+ /**
79
+ * Sets the color of text to be printed to green.
80
+ *
81
+ * Disable by setting the `NO_COLOR` environmental variable.
82
+ *
83
+ * @param str Text to make green
84
+ *
85
+ * @returns Green text for print
86
+ *
87
+ * @example Usage
88
+ * ```ts no-assert
89
+ * import { green } from "@std/internal/styles";
90
+ *
91
+ * console.log(green("Hello, world!")); // Prints "Hello, world!" in green
92
+ * ```
93
+ */
94
+ export function green(str: string): string {
95
+ return run(str, code([32], 39));
96
+ }
97
+
98
+ /**
99
+ * Sets the color of text to be printed to yellow.
100
+ *
101
+ * Disable by setting the `NO_COLOR` environmental variable.
102
+ *
103
+ * @param str Text to make yellow
104
+ *
105
+ * @returns Yellow text for print
106
+ *
107
+ * @example Usage
108
+ * ```ts no-assert
109
+ * import { yellow } from "@std/internal/styles";
110
+ *
111
+ * console.log(yellow("Hello, world!")); // Prints "Hello, world!" in yellow
112
+ * ```
113
+ */
114
+ export function yellow(str: string): string {
115
+ return run(str, code([33], 39));
116
+ }
117
+
118
+ /**
119
+ * Sets the color of text to be printed to white.
120
+ *
121
+ * @param str Text to make white
122
+ *
123
+ * @returns White text for print
124
+ *
125
+ * @example Usage
126
+ * ```ts no-assert
127
+ * import { white } from "@std/internal/styles";
128
+ *
129
+ * console.log(white("Hello, world!")); // Prints "Hello, world!" in white
130
+ * ```
131
+ */
132
+ export function white(str: string): string {
133
+ return run(str, code([37], 39));
134
+ }
135
+
136
+ /**
137
+ * Sets the color of text to be printed to gray.
138
+ *
139
+ * @param str Text to make gray
140
+ *
141
+ * @returns Gray text for print
142
+ *
143
+ * @example Usage
144
+ * ```ts no-assert
145
+ * import { gray } from "@std/internal/styles";
146
+ *
147
+ * console.log(gray("Hello, world!")); // Prints "Hello, world!" in gray
148
+ * ```
149
+ */
150
+ export function gray(str: string): string {
151
+ return brightBlack(str);
152
+ }
153
+
154
+ /**
155
+ * Sets the color of text to be printed to bright-black.
156
+ *
157
+ * @param str Text to make bright-black
158
+ *
159
+ * @returns Bright-black text for print
160
+ *
161
+ * @example Usage
162
+ * ```ts no-assert
163
+ * import { brightBlack } from "@std/internal/styles";
164
+ *
165
+ * console.log(brightBlack("Hello, world!")); // Prints "Hello, world!" in bright-black
166
+ * ```
167
+ */
168
+ export function brightBlack(str: string): string {
169
+ return run(str, code([90], 39));
170
+ }
171
+
172
+ /**
173
+ * Sets the background color of text to be printed to red.
174
+ *
175
+ * @param str Text to make its background red
176
+ *
177
+ * @returns Red background text for print
178
+ *
179
+ * @example Usage
180
+ * ```ts no-assert
181
+ * import { bgRed } from "@std/internal/styles";
182
+ *
183
+ * console.log(bgRed("Hello, world!")); // Prints "Hello, world!" with red background
184
+ * ```
185
+ */
186
+ export function bgRed(str: string): string {
187
+ return run(str, code([41], 49));
188
+ }
189
+
190
+ /**
191
+ * Sets the background color of text to be printed to green.
192
+ *
193
+ * @param str Text to make its background green
194
+ *
195
+ * @returns Green background text for print
196
+ *
197
+ * @example Usage
198
+ * ```ts no-assert
199
+ * import { bgGreen } from "@std/internal/styles";
200
+ *
201
+ * console.log(bgGreen("Hello, world!")); // Prints "Hello, world!" with green background
202
+ * ```
203
+ */
204
+ export function bgGreen(str: string): string {
205
+ return run(str, code([42], 49));
206
+ }
207
+
208
+ // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
209
+ const ANSI_PATTERN = new RegExp(
210
+ [
211
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
212
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))",
213
+ ].join("|"),
214
+ "g",
215
+ );
216
+
217
+ /**
218
+ * Remove ANSI escape codes from the string.
219
+ *
220
+ * @param string Text to remove ANSI escape codes from
221
+ *
222
+ * @returns Text without ANSI escape codes
223
+ *
224
+ * @example Usage
225
+ * ```ts no-assert
226
+ * import { red, stripAnsiCode } from "@std/internal/styles";
227
+ *
228
+ * console.log(stripAnsiCode(red("Hello, world!"))); // Prints "Hello, world!"
229
+ * ```
230
+ */
231
+ export function stripAnsiCode(string: string): string {
232
+ return string.replace(ANSI_PATTERN, "");
233
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /** Ways that lines in a diff can be different. */
5
+ export type DiffType = DiffResult<unknown>["type"];
6
+
7
+ /**
8
+ * Represents the result of a diff operation.
9
+ * @typeParam T The type of the value in the diff result.
10
+ */
11
+ export type DiffResult<T> = ChangedDiffResult<T> | CommonDiffResult<T>;
12
+
13
+ /**
14
+ * Represents the result of a common diff operation.
15
+ * @typeParam T The type of the value in the diff result.
16
+ */
17
+ export type CommonDiffResult<T> = {
18
+ type: "common" | "truncation";
19
+ value: T;
20
+ };
21
+
22
+ /**
23
+ * Represents the result of a changed diff operation.
24
+ * @typeParam T The type of the value in the diff result.
25
+ */
26
+ export type ChangedDiffResult<T> = {
27
+ type: "removed" | "added";
28
+ value: T;
29
+ details?: DiffResult<T>[];
30
+ };
@@ -0,0 +1,12 @@
1
+ export { assertEquals } from './deps/jsr.io/@std/assert/1.0.16/mod.js';
2
+
3
+ export function trimLines(args: TemplateStringsArray) {
4
+ const lines = args[0].split('\n');
5
+ if (!lines[0].trim()) {
6
+ lines.shift();
7
+ }
8
+ if (!lines[lines.length - 1].trim()) {
9
+ lines[lines.length - 1] = '';
10
+ }
11
+ return lines.join('\n');
12
+ }