ventojs 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +138 -0
- package/esm/_dnt.shims.d.ts +5 -0
- package/esm/_dnt.shims.js +62 -0
- package/esm/_dnt.test_polyfills.d.ts +11 -0
- package/esm/_dnt.test_shims.d.ts +5 -0
- package/esm/deps/deno.land/std@0.178.0/_util/asserts.d.ts +10 -0
- package/esm/deps/deno.land/std@0.178.0/_util/asserts.js +21 -0
- package/esm/deps/deno.land/std@0.178.0/_util/os.d.ts +4 -0
- package/esm/deps/deno.land/std@0.178.0/_util/os.js +18 -0
- package/esm/deps/deno.land/std@0.178.0/path/_constants.d.ts +39 -0
- package/esm/deps/deno.land/std@0.178.0/path/_constants.js +46 -0
- package/esm/deps/deno.land/std@0.178.0/path/_interface.d.ts +26 -0
- package/esm/deps/deno.land/std@0.178.0/path/_interface.js +3 -0
- package/esm/deps/deno.land/std@0.178.0/path/_util.d.ts +11 -0
- package/esm/deps/deno.land/std@0.178.0/path/_util.js +161 -0
- package/esm/deps/deno.land/std@0.178.0/path/common.d.ts +13 -0
- package/esm/deps/deno.land/std@0.178.0/path/common.js +36 -0
- package/esm/deps/deno.land/std@0.178.0/path/glob.d.ts +83 -0
- package/esm/deps/deno.land/std@0.178.0/path/glob.js +361 -0
- package/esm/deps/deno.land/std@0.178.0/path/mod.d.ts +9 -0
- package/esm/deps/deno.land/std@0.178.0/path/mod.js +32 -0
- package/esm/deps/deno.land/std@0.178.0/path/posix.d.ts +86 -0
- package/esm/deps/deno.land/std@0.178.0/path/posix.js +442 -0
- package/esm/deps/deno.land/std@0.178.0/path/separator.d.ts +2 -0
- package/esm/deps/deno.land/std@0.178.0/path/separator.js +5 -0
- package/esm/deps/deno.land/std@0.178.0/path/win32.d.ts +91 -0
- package/esm/deps/deno.land/std@0.178.0/path/win32.js +909 -0
- package/esm/deps/deno.land/std@0.190.0/_util/asserts.d.ts +10 -0
- package/esm/deps/deno.land/std@0.190.0/bytes/copy.d.ts +27 -0
- package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.190.0/front_matter/mod.d.ts +78 -0
- package/esm/deps/deno.land/std@0.190.0/front_matter/yaml.d.ts +4 -0
- package/esm/deps/deno.land/std@0.190.0/io/buffer.d.ts +81 -0
- package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +26 -0
- package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +1 -0
- package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +284 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_error.d.ts +6 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader.d.ts +4 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader_state.d.ts +43 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_mark.d.ts +10 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_state.d.ts +5 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/binary.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/bool.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/float.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/function.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/int.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/map.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/merge.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/mod.d.ts +16 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/nil.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/omap.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/pairs.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/regexp.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/seq.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/set.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/str.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/timestamp.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/undefined.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/_utils.d.ts +19 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/parse.d.ts +35 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/core.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/default.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/extended.d.ts +30 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/failsafe.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/json.d.ts +2 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/mod.d.ts +5 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/schema.d.ts +22 -0
- package/esm/deps/deno.land/std@0.190.0/yaml/type.d.ts +28 -0
- package/esm/deps.d.ts +1 -0
- package/esm/deps.js +1 -0
- package/esm/mod.d.ts +7 -0
- package/esm/mod.js +28 -0
- package/esm/package.json +3 -0
- package/esm/plugins/escape.d.ts +2 -0
- package/esm/plugins/escape.js +16 -0
- package/esm/plugins/for.d.ts +2 -0
- package/esm/plugins/for.js +48 -0
- package/esm/plugins/if.d.ts +2 -0
- package/esm/plugins/if.js +32 -0
- package/esm/plugins/include.d.ts +2 -0
- package/esm/plugins/include.js +16 -0
- package/esm/plugins/js.d.ts +2 -0
- package/esm/plugins/js.js +11 -0
- package/esm/plugins/layout.d.ts +2 -0
- package/esm/plugins/layout.js +29 -0
- package/esm/plugins/set.d.ts +2 -0
- package/esm/plugins/set.js +44 -0
- package/esm/src/environment.d.ts +29 -0
- package/esm/src/environment.js +136 -0
- package/esm/src/loader.d.ts +14 -0
- package/esm/src/loader.js +19 -0
- package/esm/src/tokenizer.d.ts +8 -0
- package/esm/src/tokenizer.js +197 -0
- package/esm/test/comment.test.d.ts +1 -0
- package/esm/test/escape.test.d.ts +1 -0
- package/esm/test/for.test.d.ts +1 -0
- package/esm/test/if.test.d.ts +1 -0
- package/esm/test/include.test.d.ts +1 -0
- package/esm/test/js.test.d.ts +1 -0
- package/esm/test/layout.test.d.ts +1 -0
- package/esm/test/print.test.d.ts +1 -0
- package/esm/test/raw.test.d.ts +1 -0
- package/esm/test/set.test.d.ts +1 -0
- package/esm/test/tokenizer.test.d.ts +1 -0
- package/esm/test/utils.d.ts +23 -0
- package/package.json +25 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All internal non-test code, that is files that do not have `test` or `bench` in the name, must use the assertion functions within `_utils/asserts.ts` and not `testing/asserts.ts`. This is to create a separation of concerns between internal and testing assertions.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DenoStdInternalError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/** Make an assertion, if not `true`, then throw. */
|
|
8
|
+
export declare function assert(expr: unknown, msg?: string): asserts expr;
|
|
9
|
+
/** Use this to assert unreachable code. */
|
|
10
|
+
export declare function unreachable(): never;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Copy bytes from the `src` array to the `dst` array. Returns the number of
|
|
2
|
+
* bytes copied.
|
|
3
|
+
*
|
|
4
|
+
* If the `src` array is larger than what the `dst` array can hold, only the
|
|
5
|
+
* amount of bytes that fit in the `dst` array are copied.
|
|
6
|
+
*
|
|
7
|
+
* An offset can be specified as the third argument that begins the copy at
|
|
8
|
+
* that given index in the `dst` array. The offset defaults to the beginning of
|
|
9
|
+
* the array.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { copy } from "https://deno.land/std@$STD_VERSION/bytes/copy.ts";
|
|
13
|
+
* const src = new Uint8Array([9, 8, 7]);
|
|
14
|
+
* const dst = new Uint8Array([0, 1, 2, 3, 4, 5]);
|
|
15
|
+
* console.log(copy(src, dst)); // 3
|
|
16
|
+
* console.log(dst); // [9, 8, 7, 3, 4, 5]
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { copy } from "https://deno.land/std@$STD_VERSION/bytes/copy.ts";
|
|
21
|
+
* const src = new Uint8Array([1, 1, 1, 1]);
|
|
22
|
+
* const dst = new Uint8Array([0, 0, 0, 0]);
|
|
23
|
+
* console.log(copy(src, dst, 1)); // 3
|
|
24
|
+
* console.log(dst); // [0, 1, 1, 1]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function copy(src: Uint8Array, dst: Uint8Array, off?: number): number;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */
|
|
2
|
+
interface Rgb {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Set changing text color to enabled or disabled
|
|
9
|
+
* @param value
|
|
10
|
+
*/
|
|
11
|
+
export declare function setColorEnabled(value: boolean): void;
|
|
12
|
+
/** Get whether text color change is enabled or disabled. */
|
|
13
|
+
export declare function getColorEnabled(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Reset the text modified
|
|
16
|
+
* @param str text to reset
|
|
17
|
+
*/
|
|
18
|
+
export declare function reset(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Make the text bold.
|
|
21
|
+
* @param str text to make bold
|
|
22
|
+
*/
|
|
23
|
+
export declare function bold(str: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* The text emits only a small amount of light.
|
|
26
|
+
* @param str text to dim
|
|
27
|
+
*/
|
|
28
|
+
export declare function dim(str: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Make the text italic.
|
|
31
|
+
* @param str text to make italic
|
|
32
|
+
*/
|
|
33
|
+
export declare function italic(str: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Make the text underline.
|
|
36
|
+
* @param str text to underline
|
|
37
|
+
*/
|
|
38
|
+
export declare function underline(str: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Invert background color and text color.
|
|
41
|
+
* @param str text to invert its color
|
|
42
|
+
*/
|
|
43
|
+
export declare function inverse(str: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Make the text hidden.
|
|
46
|
+
* @param str text to hide
|
|
47
|
+
*/
|
|
48
|
+
export declare function hidden(str: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Put horizontal line through the center of the text.
|
|
51
|
+
* @param str text to strike through
|
|
52
|
+
*/
|
|
53
|
+
export declare function strikethrough(str: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Set text color to black.
|
|
56
|
+
* @param str text to make black
|
|
57
|
+
*/
|
|
58
|
+
export declare function black(str: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Set text color to red.
|
|
61
|
+
* @param str text to make red
|
|
62
|
+
*/
|
|
63
|
+
export declare function red(str: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Set text color to green.
|
|
66
|
+
* @param str text to make green
|
|
67
|
+
*/
|
|
68
|
+
export declare function green(str: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Set text color to yellow.
|
|
71
|
+
* @param str text to make yellow
|
|
72
|
+
*/
|
|
73
|
+
export declare function yellow(str: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Set text color to blue.
|
|
76
|
+
* @param str text to make blue
|
|
77
|
+
*/
|
|
78
|
+
export declare function blue(str: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Set text color to magenta.
|
|
81
|
+
* @param str text to make magenta
|
|
82
|
+
*/
|
|
83
|
+
export declare function magenta(str: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Set text color to cyan.
|
|
86
|
+
* @param str text to make cyan
|
|
87
|
+
*/
|
|
88
|
+
export declare function cyan(str: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Set text color to white.
|
|
91
|
+
* @param str text to make white
|
|
92
|
+
*/
|
|
93
|
+
export declare function white(str: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Set text color to gray.
|
|
96
|
+
* @param str text to make gray
|
|
97
|
+
*/
|
|
98
|
+
export declare function gray(str: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Set text color to bright black.
|
|
101
|
+
* @param str text to make bright-black
|
|
102
|
+
*/
|
|
103
|
+
export declare function brightBlack(str: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Set text color to bright red.
|
|
106
|
+
* @param str text to make bright-red
|
|
107
|
+
*/
|
|
108
|
+
export declare function brightRed(str: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Set text color to bright green.
|
|
111
|
+
* @param str text to make bright-green
|
|
112
|
+
*/
|
|
113
|
+
export declare function brightGreen(str: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Set text color to bright yellow.
|
|
116
|
+
* @param str text to make bright-yellow
|
|
117
|
+
*/
|
|
118
|
+
export declare function brightYellow(str: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Set text color to bright blue.
|
|
121
|
+
* @param str text to make bright-blue
|
|
122
|
+
*/
|
|
123
|
+
export declare function brightBlue(str: string): string;
|
|
124
|
+
/**
|
|
125
|
+
* Set text color to bright magenta.
|
|
126
|
+
* @param str text to make bright-magenta
|
|
127
|
+
*/
|
|
128
|
+
export declare function brightMagenta(str: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Set text color to bright cyan.
|
|
131
|
+
* @param str text to make bright-cyan
|
|
132
|
+
*/
|
|
133
|
+
export declare function brightCyan(str: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Set text color to bright white.
|
|
136
|
+
* @param str text to make bright-white
|
|
137
|
+
*/
|
|
138
|
+
export declare function brightWhite(str: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Set background color to black.
|
|
141
|
+
* @param str text to make its background black
|
|
142
|
+
*/
|
|
143
|
+
export declare function bgBlack(str: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* Set background color to red.
|
|
146
|
+
* @param str text to make its background red
|
|
147
|
+
*/
|
|
148
|
+
export declare function bgRed(str: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Set background color to green.
|
|
151
|
+
* @param str text to make its background green
|
|
152
|
+
*/
|
|
153
|
+
export declare function bgGreen(str: string): string;
|
|
154
|
+
/**
|
|
155
|
+
* Set background color to yellow.
|
|
156
|
+
* @param str text to make its background yellow
|
|
157
|
+
*/
|
|
158
|
+
export declare function bgYellow(str: string): string;
|
|
159
|
+
/**
|
|
160
|
+
* Set background color to blue.
|
|
161
|
+
* @param str text to make its background blue
|
|
162
|
+
*/
|
|
163
|
+
export declare function bgBlue(str: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* Set background color to magenta.
|
|
166
|
+
* @param str text to make its background magenta
|
|
167
|
+
*/
|
|
168
|
+
export declare function bgMagenta(str: string): string;
|
|
169
|
+
/**
|
|
170
|
+
* Set background color to cyan.
|
|
171
|
+
* @param str text to make its background cyan
|
|
172
|
+
*/
|
|
173
|
+
export declare function bgCyan(str: string): string;
|
|
174
|
+
/**
|
|
175
|
+
* Set background color to white.
|
|
176
|
+
* @param str text to make its background white
|
|
177
|
+
*/
|
|
178
|
+
export declare function bgWhite(str: string): string;
|
|
179
|
+
/**
|
|
180
|
+
* Set background color to bright black.
|
|
181
|
+
* @param str text to make its background bright-black
|
|
182
|
+
*/
|
|
183
|
+
export declare function bgBrightBlack(str: string): string;
|
|
184
|
+
/**
|
|
185
|
+
* Set background color to bright red.
|
|
186
|
+
* @param str text to make its background bright-red
|
|
187
|
+
*/
|
|
188
|
+
export declare function bgBrightRed(str: string): string;
|
|
189
|
+
/**
|
|
190
|
+
* Set background color to bright green.
|
|
191
|
+
* @param str text to make its background bright-green
|
|
192
|
+
*/
|
|
193
|
+
export declare function bgBrightGreen(str: string): string;
|
|
194
|
+
/**
|
|
195
|
+
* Set background color to bright yellow.
|
|
196
|
+
* @param str text to make its background bright-yellow
|
|
197
|
+
*/
|
|
198
|
+
export declare function bgBrightYellow(str: string): string;
|
|
199
|
+
/**
|
|
200
|
+
* Set background color to bright blue.
|
|
201
|
+
* @param str text to make its background bright-blue
|
|
202
|
+
*/
|
|
203
|
+
export declare function bgBrightBlue(str: string): string;
|
|
204
|
+
/**
|
|
205
|
+
* Set background color to bright magenta.
|
|
206
|
+
* @param str text to make its background bright-magenta
|
|
207
|
+
*/
|
|
208
|
+
export declare function bgBrightMagenta(str: string): string;
|
|
209
|
+
/**
|
|
210
|
+
* Set background color to bright cyan.
|
|
211
|
+
* @param str text to make its background bright-cyan
|
|
212
|
+
*/
|
|
213
|
+
export declare function bgBrightCyan(str: string): string;
|
|
214
|
+
/**
|
|
215
|
+
* Set background color to bright white.
|
|
216
|
+
* @param str text to make its background bright-white
|
|
217
|
+
*/
|
|
218
|
+
export declare function bgBrightWhite(str: string): string;
|
|
219
|
+
/**
|
|
220
|
+
* Set text color using paletted 8bit colors.
|
|
221
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
222
|
+
* @param str text color to apply paletted 8bit colors to
|
|
223
|
+
* @param color code
|
|
224
|
+
*/
|
|
225
|
+
export declare function rgb8(str: string, color: number): string;
|
|
226
|
+
/**
|
|
227
|
+
* Set background color using paletted 8bit colors.
|
|
228
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
229
|
+
* @param str text color to apply paletted 8bit background colors to
|
|
230
|
+
* @param color code
|
|
231
|
+
*/
|
|
232
|
+
export declare function bgRgb8(str: string, color: number): string;
|
|
233
|
+
/**
|
|
234
|
+
* Set text color using 24bit rgb.
|
|
235
|
+
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
236
|
+
* an `Rgb`.
|
|
237
|
+
*
|
|
238
|
+
* To produce the color magenta:
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { rgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
|
242
|
+
* rgb24("foo", 0xff00ff);
|
|
243
|
+
* rgb24("foo", {r: 255, g: 0, b: 255});
|
|
244
|
+
* ```
|
|
245
|
+
* @param str text color to apply 24bit rgb to
|
|
246
|
+
* @param color code
|
|
247
|
+
*/
|
|
248
|
+
export declare function rgb24(str: string, color: number | Rgb): string;
|
|
249
|
+
/**
|
|
250
|
+
* Set background color using 24bit rgb.
|
|
251
|
+
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
252
|
+
* an `Rgb`.
|
|
253
|
+
*
|
|
254
|
+
* To produce the color magenta:
|
|
255
|
+
*
|
|
256
|
+
* ```ts
|
|
257
|
+
* import { bgRgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
|
258
|
+
* bgRgb24("foo", 0xff00ff);
|
|
259
|
+
* bgRgb24("foo", {r: 255, g: 0, b: 255});
|
|
260
|
+
* ```
|
|
261
|
+
* @param str text color to apply 24bit rgb to
|
|
262
|
+
* @param color code
|
|
263
|
+
*/
|
|
264
|
+
export declare function bgRgb24(str: string, color: number | Rgb): string;
|
|
265
|
+
/**
|
|
266
|
+
* Remove ANSI escape codes from the string.
|
|
267
|
+
* @param string to remove ANSI escape codes from
|
|
268
|
+
*/
|
|
269
|
+
export declare function stripColor(string: string): string;
|
|
270
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export type Parser = <T = Record<string, unknown>>(str: string) => T;
|
|
2
|
+
export type Extractor = <T = Record<string, unknown>>(str: string) => Extract<T>;
|
|
3
|
+
export declare enum Format {
|
|
4
|
+
YAML = "yaml",
|
|
5
|
+
TOML = "toml",
|
|
6
|
+
JSON = "json",
|
|
7
|
+
UNKNOWN = "unknown"
|
|
8
|
+
}
|
|
9
|
+
export type Extract<T> = {
|
|
10
|
+
frontMatter: string;
|
|
11
|
+
body: string;
|
|
12
|
+
attrs: T;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Factory that creates a function that extracts front matter from a string with the given parsers.
|
|
16
|
+
* Supports YAML, TOML and JSON.
|
|
17
|
+
*
|
|
18
|
+
* @param formats A descriptor containing Format-parser pairs to use for each format.
|
|
19
|
+
* @returns A function that extracts front matter from a string with the given parsers.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createExtractor, Format, Parser } from "https://deno.land/std@$STD_VERSION/front_matter/mod.ts";
|
|
23
|
+
* import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
24
|
+
* import { parse as parseYAML } from "https://deno.land/std@$STD_VERSION/yaml/parse.ts";
|
|
25
|
+
* import { parse as parseTOML } from "https://deno.land/std@$STD_VERSION/toml/parse.ts";
|
|
26
|
+
* const extractYAML = createExtractor({ [Format.YAML]: parseYAML as Parser });
|
|
27
|
+
* const extractTOML = createExtractor({ [Format.TOML]: parseTOML as Parser });
|
|
28
|
+
* const extractJSON = createExtractor({ [Format.JSON]: JSON.parse as Parser });
|
|
29
|
+
* const extractYAMLOrJSON = createExtractor({
|
|
30
|
+
* [Format.YAML]: parseYAML as Parser,
|
|
31
|
+
* [Format.JSON]: JSON.parse as Parser,
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* let { attrs, body, frontMatter } = extractYAML<{ title: string }>("---\ntitle: Three dashes marks the spot\n---\nferret");
|
|
35
|
+
* assertEquals(attrs.title, "Three dashes marks the spot");
|
|
36
|
+
* assertEquals(body, "ferret");
|
|
37
|
+
* assertEquals(frontMatter, "title: Three dashes marks the spot");
|
|
38
|
+
*
|
|
39
|
+
* ({ attrs, body, frontMatter } = extractTOML<{ title: string }>("---toml\ntitle = 'Three dashes followed by format marks the spot'\n---\n"));
|
|
40
|
+
* assertEquals(attrs.title, "Three dashes followed by format marks the spot");
|
|
41
|
+
* assertEquals(body, "");
|
|
42
|
+
* assertEquals(frontMatter, "title = 'Three dashes followed by format marks the spot'");
|
|
43
|
+
*
|
|
44
|
+
* ({ attrs, body, frontMatter } = extractJSON<{ title: string }>("---json\n{\"title\": \"Three dashes followed by format marks the spot\"}\n---\ngoat"));
|
|
45
|
+
* assertEquals(attrs.title, "Three dashes followed by format marks the spot");
|
|
46
|
+
* assertEquals(body, "goat");
|
|
47
|
+
* assertEquals(frontMatter, "{\"title\": \"Three dashes followed by format marks the spot\"}");
|
|
48
|
+
*
|
|
49
|
+
* ({ attrs, body, frontMatter } = extractYAMLOrJSON<{ title: string }>("---\ntitle: Three dashes marks the spot\n---\nferret"));
|
|
50
|
+
* assertEquals(attrs.title, "Three dashes marks the spot");
|
|
51
|
+
* assertEquals(body, "ferret");
|
|
52
|
+
* assertEquals(frontMatter, "title: Three dashes marks the spot");
|
|
53
|
+
*
|
|
54
|
+
* ({ attrs, body, frontMatter } = extractYAMLOrJSON<{ title: string }>("---json\n{\"title\": \"Three dashes followed by format marks the spot\"}\n---\ngoat"));
|
|
55
|
+
* assertEquals(attrs.title, "Three dashes followed by format marks the spot");
|
|
56
|
+
* assertEquals(body, "goat");
|
|
57
|
+
* assertEquals(frontMatter, "{\"title\": \"Three dashes followed by format marks the spot\"}");
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function createExtractor(formats: Partial<Record<Format, Parser>>): Extractor;
|
|
61
|
+
/**
|
|
62
|
+
* Tests if a string has valid front matter. Supports YAML, TOML and JSON.
|
|
63
|
+
*
|
|
64
|
+
* @param str String to test.
|
|
65
|
+
* @param formats A list of formats to test for. Defaults to all supported formats.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { test, Format } from "https://deno.land/std@$STD_VERSION/front_matter/mod.ts";
|
|
69
|
+
* import { assert } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
70
|
+
*
|
|
71
|
+
* assert(test("---\ntitle: Three dashes marks the spot\n---\n"));
|
|
72
|
+
* assert(test("---toml\ntitle = 'Three dashes followed by format marks the spot'\n---\n"));
|
|
73
|
+
* assert(test("---json\n{\"title\": \"Three dashes followed by format marks the spot\"}\n---\n"));
|
|
74
|
+
*
|
|
75
|
+
* assert(!test("---json\n{\"title\": \"Three dashes followed by format marks the spot\"}\n---\n", [Format.YAML]));
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function test(str: string, formats?: Format[]): boolean;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Reader, ReaderSync } from "../types";
|
|
2
|
+
/** A variable-sized buffer of bytes with `read()` and `write()` methods.
|
|
3
|
+
*
|
|
4
|
+
* Buffer is almost always used with some I/O like files and sockets. It allows
|
|
5
|
+
* one to buffer up a download from a socket. Buffer grows and shrinks as
|
|
6
|
+
* necessary.
|
|
7
|
+
*
|
|
8
|
+
* Buffer is NOT the same thing as Node's Buffer. Node's Buffer was created in
|
|
9
|
+
* 2009 before JavaScript had the concept of ArrayBuffers. It's simply a
|
|
10
|
+
* non-standard ArrayBuffer.
|
|
11
|
+
*
|
|
12
|
+
* ArrayBuffer is a fixed memory allocation. Buffer is implemented on top of
|
|
13
|
+
* ArrayBuffer.
|
|
14
|
+
*
|
|
15
|
+
* Based on [Go Buffer](https://golang.org/pkg/bytes/#Buffer). */
|
|
16
|
+
export declare class Buffer {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(ab?: ArrayBufferLike | ArrayLike<number>);
|
|
19
|
+
/** Returns a slice holding the unread portion of the buffer.
|
|
20
|
+
*
|
|
21
|
+
* The slice is valid for use only until the next buffer modification (that
|
|
22
|
+
* is, only until the next call to a method like `read()`, `write()`,
|
|
23
|
+
* `reset()`, or `truncate()`). If `options.copy` is false the slice aliases the buffer content at
|
|
24
|
+
* least until the next buffer modification, so immediate changes to the
|
|
25
|
+
* slice will affect the result of future reads.
|
|
26
|
+
* @param [options={ copy: true }]
|
|
27
|
+
*/
|
|
28
|
+
bytes(options?: {
|
|
29
|
+
copy: boolean;
|
|
30
|
+
}): Uint8Array;
|
|
31
|
+
/** Returns whether the unread portion of the buffer is empty. */
|
|
32
|
+
empty(): boolean;
|
|
33
|
+
/** A read only number of bytes of the unread portion of the buffer. */
|
|
34
|
+
get length(): number;
|
|
35
|
+
/** The read only capacity of the buffer's underlying byte slice, that is,
|
|
36
|
+
* the total space allocated for the buffer's data. */
|
|
37
|
+
get capacity(): number;
|
|
38
|
+
/** Discards all but the first `n` unread bytes from the buffer but
|
|
39
|
+
* continues to use the same allocated storage. It throws if `n` is
|
|
40
|
+
* negative or greater than the length of the buffer. */
|
|
41
|
+
truncate(n: number): void;
|
|
42
|
+
reset(): void;
|
|
43
|
+
/** Reads the next `p.length` bytes from the buffer or until the buffer is
|
|
44
|
+
* drained. Returns the number of bytes read. If the buffer has no data to
|
|
45
|
+
* return, the return is EOF (`null`). */
|
|
46
|
+
readSync(p: Uint8Array): number | null;
|
|
47
|
+
/** Reads the next `p.length` bytes from the buffer or until the buffer is
|
|
48
|
+
* drained. Resolves to the number of bytes read. If the buffer has no
|
|
49
|
+
* data to return, resolves to EOF (`null`).
|
|
50
|
+
*
|
|
51
|
+
* NOTE: This methods reads bytes synchronously; it's provided for
|
|
52
|
+
* compatibility with `Reader` interfaces.
|
|
53
|
+
*/
|
|
54
|
+
read(p: Uint8Array): Promise<number | null>;
|
|
55
|
+
writeSync(p: Uint8Array): number;
|
|
56
|
+
/** NOTE: This methods writes bytes synchronously; it's provided for
|
|
57
|
+
* compatibility with `Writer` interface. */
|
|
58
|
+
write(p: Uint8Array): Promise<number>;
|
|
59
|
+
/** Grows the buffer's capacity, if necessary, to guarantee space for
|
|
60
|
+
* another `n` bytes. After `.grow(n)`, at least `n` bytes can be written to
|
|
61
|
+
* the buffer without another allocation. If `n` is negative, `.grow()` will
|
|
62
|
+
* throw. If the buffer can't grow it will throw an error.
|
|
63
|
+
*
|
|
64
|
+
* Based on Go Lang's
|
|
65
|
+
* [Buffer.Grow](https://golang.org/pkg/bytes/#Buffer.Grow). */
|
|
66
|
+
grow(n: number): void;
|
|
67
|
+
/** Reads data from `r` until EOF (`null`) and appends it to the buffer,
|
|
68
|
+
* growing the buffer as needed. It resolves to the number of bytes read.
|
|
69
|
+
* If the buffer becomes too large, `.readFrom()` will reject with an error.
|
|
70
|
+
*
|
|
71
|
+
* Based on Go Lang's
|
|
72
|
+
* [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */
|
|
73
|
+
readFrom(r: Reader): Promise<number>;
|
|
74
|
+
/** Reads data from `r` until EOF (`null`) and appends it to the buffer,
|
|
75
|
+
* growing the buffer as needed. It returns the number of bytes read. If the
|
|
76
|
+
* buffer becomes too large, `.readFromSync()` will throw an error.
|
|
77
|
+
*
|
|
78
|
+
* Based on Go Lang's
|
|
79
|
+
* [Buffer.ReadFrom](https://golang.org/pkg/bytes/#Buffer.ReadFrom). */
|
|
80
|
+
readFromSync(r: ReaderSync): number;
|
|
81
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare enum DiffType {
|
|
2
|
+
removed = "removed",
|
|
3
|
+
common = "common",
|
|
4
|
+
added = "added"
|
|
5
|
+
}
|
|
6
|
+
export interface DiffResult<T> {
|
|
7
|
+
type: DiffType;
|
|
8
|
+
value: T;
|
|
9
|
+
details?: Array<DiffResult<T>>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Renders the differences between the actual and expected values
|
|
13
|
+
* @param A Actual value
|
|
14
|
+
* @param B Expected value
|
|
15
|
+
*/
|
|
16
|
+
export declare function diff<T>(A: T[], B: T[]): Array<DiffResult<T>>;
|
|
17
|
+
/**
|
|
18
|
+
* Renders the differences between the actual and expected strings
|
|
19
|
+
* Partially inspired from https://github.com/kpdecker/jsdiff
|
|
20
|
+
* @param A Actual string
|
|
21
|
+
* @param B Expected string
|
|
22
|
+
*/
|
|
23
|
+
export declare function diffstr(A: string, B: string): DiffResult<string>[];
|
|
24
|
+
export declare function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>, { stringDiff }?: {
|
|
25
|
+
stringDiff?: boolean | undefined;
|
|
26
|
+
}): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function format(v: unknown): string;
|