@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,183 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { diff } from "./diff.js";
4
+ /**
5
+ * Unescape invisible characters.
6
+ *
7
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#escape_sequences}
8
+ *
9
+ * @param string String to unescape.
10
+ *
11
+ * @returns Unescaped string.
12
+ *
13
+ * @example Usage
14
+ * ```ts
15
+ * import { unescape } from "@std/internal/diff-str";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * assertEquals(unescape("Hello\nWorld"), "Hello\\n\nWorld");
19
+ * ```
20
+ */
21
+ export function unescape(string) {
22
+ return string
23
+ .replaceAll("\\", "\\\\")
24
+ .replaceAll("\b", "\\b")
25
+ .replaceAll("\f", "\\f")
26
+ .replaceAll("\t", "\\t")
27
+ .replaceAll("\v", "\\v")
28
+ // This does not remove line breaks
29
+ .replaceAll(/\r\n|\r|\n/g, (str) => str === "\r" ? "\\r" : str === "\n" ? "\\n\n" : "\\r\\n\r\n");
30
+ }
31
+ const WHITESPACE_SYMBOLS = /((?:\\[bftv]|[^\S\r\n])+|\\[rn\\]|[()[\]{}'"\r\n]|\b)/;
32
+ /**
33
+ * Tokenizes a string into an array of tokens.
34
+ *
35
+ * @param string The string to tokenize.
36
+ * @param wordDiff If true, performs word-based tokenization. Default is false.
37
+ *
38
+ * @returns An array of tokens.
39
+ *
40
+ * @example Usage
41
+ * ```ts
42
+ * import { tokenize } from "@std/internal/diff-str";
43
+ * import { assertEquals } from "@std/assert";
44
+ *
45
+ * assertEquals(tokenize("Hello\nWorld"), ["Hello\n", "World"]);
46
+ * ```
47
+ */
48
+ export function tokenize(string, wordDiff = false) {
49
+ if (wordDiff) {
50
+ return string
51
+ .split(WHITESPACE_SYMBOLS)
52
+ .filter((token) => token);
53
+ }
54
+ const tokens = [];
55
+ const lines = string.split(/(\n|\r\n)/).filter((line) => line);
56
+ for (const [i, line] of lines.entries()) {
57
+ if (i % 2) {
58
+ tokens[tokens.length - 1] += line;
59
+ }
60
+ else {
61
+ tokens.push(line);
62
+ }
63
+ }
64
+ return tokens;
65
+ }
66
+ /**
67
+ * Create details by filtering relevant word-diff for current line and merge
68
+ * "space-diff" if surrounded by word-diff for cleaner displays.
69
+ *
70
+ * @param line Current line
71
+ * @param tokens Word-diff tokens
72
+ *
73
+ * @returns Array of diff results.
74
+ *
75
+ * @example Usage
76
+ * ```ts
77
+ * import { createDetails } from "@std/internal/diff-str";
78
+ * import { assertEquals } from "@std/assert";
79
+ *
80
+ * const tokens = [
81
+ * { type: "added", value: "a" },
82
+ * { type: "removed", value: "b" },
83
+ * { type: "common", value: "c" },
84
+ * ] as const;
85
+ * assertEquals(
86
+ * createDetails({ type: "added", value: "a" }, [...tokens]),
87
+ * [{ type: "added", value: "a" }, { type: "common", value: "c" }]
88
+ * );
89
+ * ```
90
+ */
91
+ export function createDetails(line, tokens) {
92
+ return tokens.filter(({ type }) => type === line.type || type === "common")
93
+ .map((result, i, t) => {
94
+ const token = t[i - 1];
95
+ if ((result.type === "common") && token &&
96
+ (token.type === t[i + 1]?.type) && /\s+/.test(result.value)) {
97
+ return {
98
+ ...result,
99
+ type: token.type,
100
+ };
101
+ }
102
+ return result;
103
+ });
104
+ }
105
+ const NON_WHITESPACE_REGEXP = /\S/;
106
+ /**
107
+ * Renders the differences between the actual and expected strings. Partially
108
+ * inspired from {@link https://github.com/kpdecker/jsdiff}.
109
+ *
110
+ * @param A Actual string
111
+ * @param B Expected string
112
+ *
113
+ * @returns Array of diff results.
114
+ *
115
+ * @example Usage
116
+ * ```ts
117
+ * import { diffStr } from "@std/internal/diff-str";
118
+ * import { assertEquals } from "@std/assert";
119
+ *
120
+ * assertEquals(diffStr("Hello!", "Hello"), [
121
+ * {
122
+ * type: "removed",
123
+ * value: "Hello!\n",
124
+ * details: [
125
+ * { type: "common", value: "Hello" },
126
+ * { type: "removed", value: "!" },
127
+ * { type: "common", value: "\n" }
128
+ * ]
129
+ * },
130
+ * {
131
+ * type: "added",
132
+ * value: "Hello\n",
133
+ * details: [
134
+ * { type: "common", value: "Hello" },
135
+ * { type: "common", value: "\n" }
136
+ * ]
137
+ * }
138
+ * ]);
139
+ * ```
140
+ */
141
+ export function diffStr(A, B) {
142
+ // Compute multi-line diff
143
+ const diffResult = diff(tokenize(`${unescape(A)}\n`), tokenize(`${unescape(B)}\n`));
144
+ const added = [];
145
+ const removed = [];
146
+ for (const result of diffResult) {
147
+ if (result.type === "added") {
148
+ added.push(result);
149
+ }
150
+ if (result.type === "removed") {
151
+ removed.push(result);
152
+ }
153
+ }
154
+ // Compute word-diff
155
+ const hasMoreRemovedLines = added.length < removed.length;
156
+ const aLines = hasMoreRemovedLines ? added : removed;
157
+ const bLines = hasMoreRemovedLines ? removed : added;
158
+ for (const a of aLines) {
159
+ let tokens = [];
160
+ let b;
161
+ // Search another diff line with at least one common token
162
+ while (bLines.length) {
163
+ b = bLines.shift();
164
+ const tokenized = [
165
+ tokenize(a.value, true),
166
+ tokenize(b.value, true),
167
+ ];
168
+ if (hasMoreRemovedLines)
169
+ tokenized.reverse();
170
+ tokens = diff(tokenized[0], tokenized[1]);
171
+ if (tokens.some(({ type, value }) => type === "common" && NON_WHITESPACE_REGEXP.test(value))) {
172
+ break;
173
+ }
174
+ }
175
+ // Register word-diff details
176
+ a.details = createDetails(a, tokens);
177
+ if (b) {
178
+ b.details = createDetails(b, tokens);
179
+ }
180
+ }
181
+ return diffResult;
182
+ }
183
+ //# sourceMappingURL=diff_str.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff_str.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/diff_str.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AAGrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM;SACV,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC;SACxB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;SACvB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;SACvB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;SACvB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;QACxB,mCAAmC;SAClC,UAAU,CACT,aAAa,EACb,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CACtE,CAAC;AACN,CAAC;AAED,MAAM,kBAAkB,GACtB,uDAAuD,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,QAAQ,GAAG,KAAK;IACvD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,MAAM;aACV,KAAK,CAAC,kBAAkB,CAAC;aACzB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MA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,KAAK,EAAE,IAAI,CAAC;aACD,CAAC;YAC1B,IAAI,mBAAmB;gBAAE,SAAS,CAAC,OAAO,EAAE,CAAC;YAC7C,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,IACE,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAC9B,IAAI,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CACvD,EACD,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;QACD,6BAA6B;QAC7B,CAAC,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export type InspectFn = (v: unknown, options: {
2
+ depth: number;
3
+ sorted: boolean;
4
+ trailingComma: boolean;
5
+ compact: boolean;
6
+ iterableLimit: number;
7
+ getters: boolean;
8
+ strAbbreviateSize: number;
9
+ }) => string;
10
+ /**
11
+ * Converts the input into a string. Objects, Sets and Maps are sorted so as to
12
+ * make tests less flaky.
13
+ *
14
+ * @param v Value to be formatted
15
+ *
16
+ * @returns The formatted string
17
+ *
18
+ * @example Usage
19
+ * ```ts
20
+ * import { format } from "@std/internal/format";
21
+ * import { assertEquals } from "@std/assert";
22
+ *
23
+ * assertEquals(format({ a: 1, b: 2 }), "{\n a: 1,\n b: 2,\n}");
24
+ * assertEquals(format(new Set([1, 2])), "Set(2) {\n 1,\n 2,\n}");
25
+ * assertEquals(format(new Map([[1, 2]])), "Map(1) {\n 1 => 2,\n}");
26
+ * ```
27
+ */
28
+ export declare function format(v: unknown): string;
29
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/format.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,CACtB,CAAC,EAAE,OAAO,EACV,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,KACE,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAmBzC"}
@@ -0,0 +1,71 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ /** An inspect function conforming to the shape of `Deno.inspect` and `node:util`'s `inspect` */
4
+ import * as dntShim from "../../../../../_dnt.shims.js";
5
+ /**
6
+ * Converts the input into a string. Objects, Sets and Maps are sorted so as to
7
+ * make tests less flaky.
8
+ *
9
+ * @param v Value to be formatted
10
+ *
11
+ * @returns The formatted string
12
+ *
13
+ * @example Usage
14
+ * ```ts
15
+ * import { format } from "@std/internal/format";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * assertEquals(format({ a: 1, b: 2 }), "{\n a: 1,\n b: 2,\n}");
19
+ * assertEquals(format(new Set([1, 2])), "Set(2) {\n 1,\n 2,\n}");
20
+ * assertEquals(format(new Map([[1, 2]])), "Map(1) {\n 1 => 2,\n}");
21
+ * ```
22
+ */
23
+ export function format(v) {
24
+ // deno-lint-ignore no-explicit-any
25
+ const { Deno, process } = dntShim.dntGlobalThis;
26
+ const inspect = Deno?.inspect ??
27
+ process?.getBuiltinModule?.("node:util")?.inspect;
28
+ return typeof inspect === "function"
29
+ ? inspect(v, {
30
+ depth: Infinity,
31
+ sorted: true,
32
+ trailingComma: true,
33
+ compact: false,
34
+ iterableLimit: Infinity,
35
+ // getters should be true in assertEquals.
36
+ getters: true,
37
+ strAbbreviateSize: Infinity,
38
+ })
39
+ : basicInspect(v);
40
+ }
41
+ const formatters = [
42
+ (v) => {
43
+ if (typeof v === "undefined")
44
+ return "undefined";
45
+ if (typeof v === "bigint")
46
+ return `${v}n`;
47
+ if (typeof v === "string" ||
48
+ typeof v === "number" ||
49
+ typeof v === "boolean" ||
50
+ v === null ||
51
+ Array.isArray(v) ||
52
+ [null, Object.prototype].includes(Object.getPrototypeOf(v))) {
53
+ return JSON.stringify(v, null, 2);
54
+ }
55
+ },
56
+ (v) => String(v),
57
+ (v) => Object.prototype.toString.call(v),
58
+ ];
59
+ // for environments lacking both `Deno.inspect` and `process.inspect`
60
+ function basicInspect(v) {
61
+ for (const fmt of formatters) {
62
+ try {
63
+ const result = fmt(v);
64
+ if (typeof result === "string")
65
+ return result;
66
+ }
67
+ catch { /* try the next one */ }
68
+ }
69
+ return "[[Unable to format value]]";
70
+ }
71
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/format.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AAErC,gGAAgG;AAChG,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AAexD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,mCAAmC;IACnC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAoB,CAAC;IAEvD,MAAM,OAAO,GAA0B,IAAI,EAAE,OAAO;QAClD,OAAO,EAAE,gBAAgB,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAEpD,OAAO,OAAO,OAAO,KAAK,UAAU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,KAAK,QAAQ;gBAAE,OAAO,MAAM,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,4BAA4B,CAAC;AACtC,CAAC"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Sets the style of text to be printed to bold.
3
+ *
4
+ * Disable by setting the `NO_COLOR` environmental variable.
5
+ *
6
+ * @param str Text to make bold
7
+ *
8
+ * @returns Bold text for printing
9
+ *
10
+ * @example Usage
11
+ * ```ts no-assert
12
+ * import { bold } from "@std/internal/styles";
13
+ *
14
+ * console.log(bold("Hello, world!")); // Prints "Hello, world!" in bold
15
+ * ```
16
+ */
17
+ export declare function bold(str: string): string;
18
+ /**
19
+ * Sets the color of text to be printed to red.
20
+ *
21
+ * Disable by setting the `NO_COLOR` environmental variable.
22
+ *
23
+ * @param str Text to make red
24
+ *
25
+ * @returns Red text for printing
26
+ *
27
+ * @example Usage
28
+ * ```ts no-assert
29
+ * import { red } from "@std/internal/styles";
30
+ *
31
+ * console.log(red("Hello, world!")); // Prints "Hello, world!" in red
32
+ * ```
33
+ */
34
+ export declare function red(str: string): string;
35
+ /**
36
+ * Sets the color of text to be printed to green.
37
+ *
38
+ * Disable by setting the `NO_COLOR` environmental variable.
39
+ *
40
+ * @param str Text to make green
41
+ *
42
+ * @returns Green text for print
43
+ *
44
+ * @example Usage
45
+ * ```ts no-assert
46
+ * import { green } from "@std/internal/styles";
47
+ *
48
+ * console.log(green("Hello, world!")); // Prints "Hello, world!" in green
49
+ * ```
50
+ */
51
+ export declare function green(str: string): string;
52
+ /**
53
+ * Sets the color of text to be printed to yellow.
54
+ *
55
+ * Disable by setting the `NO_COLOR` environmental variable.
56
+ *
57
+ * @param str Text to make yellow
58
+ *
59
+ * @returns Yellow text for print
60
+ *
61
+ * @example Usage
62
+ * ```ts no-assert
63
+ * import { yellow } from "@std/internal/styles";
64
+ *
65
+ * console.log(yellow("Hello, world!")); // Prints "Hello, world!" in yellow
66
+ * ```
67
+ */
68
+ export declare function yellow(str: string): string;
69
+ /**
70
+ * Sets the color of text to be printed to white.
71
+ *
72
+ * @param str Text to make white
73
+ *
74
+ * @returns White text for print
75
+ *
76
+ * @example Usage
77
+ * ```ts no-assert
78
+ * import { white } from "@std/internal/styles";
79
+ *
80
+ * console.log(white("Hello, world!")); // Prints "Hello, world!" in white
81
+ * ```
82
+ */
83
+ export declare function white(str: string): string;
84
+ /**
85
+ * Sets the color of text to be printed to gray.
86
+ *
87
+ * @param str Text to make gray
88
+ *
89
+ * @returns Gray text for print
90
+ *
91
+ * @example Usage
92
+ * ```ts no-assert
93
+ * import { gray } from "@std/internal/styles";
94
+ *
95
+ * console.log(gray("Hello, world!")); // Prints "Hello, world!" in gray
96
+ * ```
97
+ */
98
+ export declare function gray(str: string): string;
99
+ /**
100
+ * Sets the color of text to be printed to bright-black.
101
+ *
102
+ * @param str Text to make bright-black
103
+ *
104
+ * @returns Bright-black text for print
105
+ *
106
+ * @example Usage
107
+ * ```ts no-assert
108
+ * import { brightBlack } from "@std/internal/styles";
109
+ *
110
+ * console.log(brightBlack("Hello, world!")); // Prints "Hello, world!" in bright-black
111
+ * ```
112
+ */
113
+ export declare function brightBlack(str: string): string;
114
+ /**
115
+ * Sets the background color of text to be printed to red.
116
+ *
117
+ * @param str Text to make its background red
118
+ *
119
+ * @returns Red background text for print
120
+ *
121
+ * @example Usage
122
+ * ```ts no-assert
123
+ * import { bgRed } from "@std/internal/styles";
124
+ *
125
+ * console.log(bgRed("Hello, world!")); // Prints "Hello, world!" with red background
126
+ * ```
127
+ */
128
+ export declare function bgRed(str: string): string;
129
+ /**
130
+ * Sets the background color of text to be printed to green.
131
+ *
132
+ * @param str Text to make its background green
133
+ *
134
+ * @returns Green background text for print
135
+ *
136
+ * @example Usage
137
+ * ```ts no-assert
138
+ * import { bgGreen } from "@std/internal/styles";
139
+ *
140
+ * console.log(bgGreen("Hello, world!")); // Prints "Hello, world!" with green background
141
+ * ```
142
+ */
143
+ export declare function bgGreen(str: string): string;
144
+ /**
145
+ * Remove ANSI escape codes from the string.
146
+ *
147
+ * @param string Text to remove ANSI escape codes from
148
+ *
149
+ * @returns Text without ANSI escape codes
150
+ *
151
+ * @example Usage
152
+ * ```ts no-assert
153
+ * import { red, stripAnsiCode } from "@std/internal/styles";
154
+ *
155
+ * console.log(stripAnsiCode(red("Hello, world!"))); // Prints "Hello, world!"
156
+ * ```
157
+ */
158
+ export declare function stripAnsiCode(string: string): string;
159
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/styles.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,208 @@
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
+ // This code is vendored from `fmt/colors.ts`.
6
+ // deno-lint-ignore no-explicit-any
7
+ import * as dntShim from "../../../../../_dnt.shims.js";
8
+ const { Deno } = dntShim.dntGlobalThis;
9
+ const noColor = typeof Deno?.noColor === "boolean"
10
+ ? Deno.noColor
11
+ : false;
12
+ const enabled = !noColor;
13
+ function code(open, close) {
14
+ return {
15
+ open: `\x1b[${open.join(";")}m`,
16
+ close: `\x1b[${close}m`,
17
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
18
+ };
19
+ }
20
+ function run(str, code) {
21
+ return enabled
22
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
23
+ : str;
24
+ }
25
+ /**
26
+ * Sets the style of text to be printed to bold.
27
+ *
28
+ * Disable by setting the `NO_COLOR` environmental variable.
29
+ *
30
+ * @param str Text to make bold
31
+ *
32
+ * @returns Bold text for printing
33
+ *
34
+ * @example Usage
35
+ * ```ts no-assert
36
+ * import { bold } from "@std/internal/styles";
37
+ *
38
+ * console.log(bold("Hello, world!")); // Prints "Hello, world!" in bold
39
+ * ```
40
+ */
41
+ export function bold(str) {
42
+ return run(str, code([1], 22));
43
+ }
44
+ /**
45
+ * Sets the color of text to be printed to red.
46
+ *
47
+ * Disable by setting the `NO_COLOR` environmental variable.
48
+ *
49
+ * @param str Text to make red
50
+ *
51
+ * @returns Red text for printing
52
+ *
53
+ * @example Usage
54
+ * ```ts no-assert
55
+ * import { red } from "@std/internal/styles";
56
+ *
57
+ * console.log(red("Hello, world!")); // Prints "Hello, world!" in red
58
+ * ```
59
+ */
60
+ export function red(str) {
61
+ return run(str, code([31], 39));
62
+ }
63
+ /**
64
+ * Sets the color of text to be printed to green.
65
+ *
66
+ * Disable by setting the `NO_COLOR` environmental variable.
67
+ *
68
+ * @param str Text to make green
69
+ *
70
+ * @returns Green text for print
71
+ *
72
+ * @example Usage
73
+ * ```ts no-assert
74
+ * import { green } from "@std/internal/styles";
75
+ *
76
+ * console.log(green("Hello, world!")); // Prints "Hello, world!" in green
77
+ * ```
78
+ */
79
+ export function green(str) {
80
+ return run(str, code([32], 39));
81
+ }
82
+ /**
83
+ * Sets the color of text to be printed to yellow.
84
+ *
85
+ * Disable by setting the `NO_COLOR` environmental variable.
86
+ *
87
+ * @param str Text to make yellow
88
+ *
89
+ * @returns Yellow text for print
90
+ *
91
+ * @example Usage
92
+ * ```ts no-assert
93
+ * import { yellow } from "@std/internal/styles";
94
+ *
95
+ * console.log(yellow("Hello, world!")); // Prints "Hello, world!" in yellow
96
+ * ```
97
+ */
98
+ export function yellow(str) {
99
+ return run(str, code([33], 39));
100
+ }
101
+ /**
102
+ * Sets the color of text to be printed to white.
103
+ *
104
+ * @param str Text to make white
105
+ *
106
+ * @returns White text for print
107
+ *
108
+ * @example Usage
109
+ * ```ts no-assert
110
+ * import { white } from "@std/internal/styles";
111
+ *
112
+ * console.log(white("Hello, world!")); // Prints "Hello, world!" in white
113
+ * ```
114
+ */
115
+ export function white(str) {
116
+ return run(str, code([37], 39));
117
+ }
118
+ /**
119
+ * Sets the color of text to be printed to gray.
120
+ *
121
+ * @param str Text to make gray
122
+ *
123
+ * @returns Gray text for print
124
+ *
125
+ * @example Usage
126
+ * ```ts no-assert
127
+ * import { gray } from "@std/internal/styles";
128
+ *
129
+ * console.log(gray("Hello, world!")); // Prints "Hello, world!" in gray
130
+ * ```
131
+ */
132
+ export function gray(str) {
133
+ return brightBlack(str);
134
+ }
135
+ /**
136
+ * Sets the color of text to be printed to bright-black.
137
+ *
138
+ * @param str Text to make bright-black
139
+ *
140
+ * @returns Bright-black text for print
141
+ *
142
+ * @example Usage
143
+ * ```ts no-assert
144
+ * import { brightBlack } from "@std/internal/styles";
145
+ *
146
+ * console.log(brightBlack("Hello, world!")); // Prints "Hello, world!" in bright-black
147
+ * ```
148
+ */
149
+ export function brightBlack(str) {
150
+ return run(str, code([90], 39));
151
+ }
152
+ /**
153
+ * Sets the background color of text to be printed to red.
154
+ *
155
+ * @param str Text to make its background red
156
+ *
157
+ * @returns Red background text for print
158
+ *
159
+ * @example Usage
160
+ * ```ts no-assert
161
+ * import { bgRed } from "@std/internal/styles";
162
+ *
163
+ * console.log(bgRed("Hello, world!")); // Prints "Hello, world!" with red background
164
+ * ```
165
+ */
166
+ export function bgRed(str) {
167
+ return run(str, code([41], 49));
168
+ }
169
+ /**
170
+ * Sets the background color of text to be printed to green.
171
+ *
172
+ * @param str Text to make its background green
173
+ *
174
+ * @returns Green background text for print
175
+ *
176
+ * @example Usage
177
+ * ```ts no-assert
178
+ * import { bgGreen } from "@std/internal/styles";
179
+ *
180
+ * console.log(bgGreen("Hello, world!")); // Prints "Hello, world!" with green background
181
+ * ```
182
+ */
183
+ export function bgGreen(str) {
184
+ return run(str, code([42], 49));
185
+ }
186
+ // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
187
+ const ANSI_PATTERN = new RegExp([
188
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
189
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))",
190
+ ].join("|"), "g");
191
+ /**
192
+ * Remove ANSI escape codes from the string.
193
+ *
194
+ * @param string Text to remove ANSI escape codes from
195
+ *
196
+ * @returns Text without ANSI escape codes
197
+ *
198
+ * @example Usage
199
+ * ```ts no-assert
200
+ * import { red, stripAnsiCode } from "@std/internal/styles";
201
+ *
202
+ * console.log(stripAnsiCode(red("Hello, world!"))); // Prints "Hello, world!"
203
+ * ```
204
+ */
205
+ export function stripAnsiCode(string) {
206
+ return string.replace(ANSI_PATTERN, "");
207
+ }
208
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.12/styles.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,qCAAqC;AACrC,+EAA+E;AAC/E,UAAU;AAEV,8CAA8C;AAE9C,mCAAmC;AACnC,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AAExD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,aAAoB,CAAC;AAC9C,MAAM,OAAO,GAAG,OAAO,IAAI,EAAE,OAAO,KAAK,SAAS;IAChD,CAAC,CAAC,IAAI,CAAC,OAAkB;IACzB,CAAC,CAAC,KAAK,CAAC;AAQV,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC;AAEzB,SAAS,IAAI,CAAC,IAAc,EAAE,KAAa;IACzC,OAAO;QACL,IAAI,EAAE,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;QAC/B,KAAK,EAAE,QAAQ,KAAK,GAAG;QACvB,MAAM,EAAE,IAAI,MAAM,CAAC,WAAW,KAAK,GAAG,EAAE,GAAG,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,SAAS,GAAG,CAAC,GAAW,EAAE,IAAU;IAClC,OAAO,OAAO;QACZ,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE;QACnE,CAAC,CAAC,GAAG,CAAC;AACV,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,GAAG,EAAE,IAAI,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