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,284 @@
|
|
|
1
|
+
export declare class AssertionError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Deep equality comparison used in assertions
|
|
7
|
+
* @param c actual value
|
|
8
|
+
* @param d expected value
|
|
9
|
+
*/
|
|
10
|
+
export declare function equal(c: unknown, d: unknown): boolean;
|
|
11
|
+
/** Make an assertion, error will be thrown if `expr` does not have truthy value. */
|
|
12
|
+
export declare function assert(expr: unknown, msg?: string): asserts expr;
|
|
13
|
+
/** Make an assertion, error will be thrown if `expr` have truthy value. */
|
|
14
|
+
type Falsy = false | 0 | 0n | "" | null | undefined;
|
|
15
|
+
export declare function assertFalse(expr: unknown, msg?: string): asserts expr is Falsy;
|
|
16
|
+
/**
|
|
17
|
+
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
|
18
|
+
* deeply equal, then throw.
|
|
19
|
+
*
|
|
20
|
+
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
25
|
+
*
|
|
26
|
+
* Deno.test("example", function (): void {
|
|
27
|
+
* assertEquals("world", "world");
|
|
28
|
+
* assertEquals({ hello: "world" }, { hello: "world" });
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Make an assertion that `actual` and `expected` are not equal, deeply.
|
|
35
|
+
* If not then throw.
|
|
36
|
+
*
|
|
37
|
+
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { assertNotEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
42
|
+
*
|
|
43
|
+
* assertNotEquals<number>(1, 2)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Make an assertion that `actual` and `expected` are strictly equal. If
|
|
49
|
+
* not then throw.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { assertStrictEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
54
|
+
*
|
|
55
|
+
* Deno.test("isStrictlyEqual", function (): void {
|
|
56
|
+
* const a = {};
|
|
57
|
+
* const b = a;
|
|
58
|
+
* assertStrictEquals(a, b);
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // This test fails
|
|
62
|
+
* Deno.test("isNotStrictlyEqual", function (): void {
|
|
63
|
+
* const a = {};
|
|
64
|
+
* const b = {};
|
|
65
|
+
* assertStrictEquals(a, b);
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T;
|
|
70
|
+
/**
|
|
71
|
+
* Make an assertion that `actual` and `expected` are not strictly equal.
|
|
72
|
+
* If the values are strictly equal then throw.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { assertNotStrictEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
76
|
+
*
|
|
77
|
+
* assertNotStrictEquals(1, 1)
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function assertNotStrictEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Make an assertion that `actual` and `expected` are almost equal numbers through
|
|
83
|
+
* a given tolerance. It can be used to take into account IEEE-754 double-precision
|
|
84
|
+
* floating-point representation limitations.
|
|
85
|
+
* If the values are not almost equal then throw.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { assertAlmostEquals, assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
90
|
+
*
|
|
91
|
+
* assertAlmostEquals(0.1, 0.2);
|
|
92
|
+
*
|
|
93
|
+
* // Using a custom tolerance value
|
|
94
|
+
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16);
|
|
95
|
+
* assertThrows(() => assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17));
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function assertAlmostEquals(actual: number, expected: number, tolerance?: number, msg?: string): void;
|
|
99
|
+
type AnyConstructor = new (...args: any[]) => any;
|
|
100
|
+
type GetConstructorType<T extends AnyConstructor> = T extends new (...args: any) => infer C ? C : never;
|
|
101
|
+
/**
|
|
102
|
+
* Make an assertion that `obj` is an instance of `type`.
|
|
103
|
+
* If not then throw.
|
|
104
|
+
*/
|
|
105
|
+
export declare function assertInstanceOf<T extends AnyConstructor>(actual: unknown, expectedType: T, msg?: string): asserts actual is GetConstructorType<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Make an assertion that `obj` is not an instance of `type`.
|
|
108
|
+
* If so, then throw.
|
|
109
|
+
*/
|
|
110
|
+
export declare function assertNotInstanceOf<A, T>(actual: A, unexpectedType: new (...args: any[]) => T, msg?: string): asserts actual is Exclude<A, T>;
|
|
111
|
+
/**
|
|
112
|
+
* Make an assertion that actual is not null or undefined.
|
|
113
|
+
* If not then throw.
|
|
114
|
+
*/
|
|
115
|
+
export declare function assertExists<T>(actual: T, msg?: string): asserts actual is NonNullable<T>;
|
|
116
|
+
/**
|
|
117
|
+
* Make an assertion that actual includes expected. If not
|
|
118
|
+
* then throw.
|
|
119
|
+
*/
|
|
120
|
+
export declare function assertStringIncludes(actual: string, expected: string, msg?: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Make an assertion that `actual` includes the `expected` values.
|
|
123
|
+
* If not then an error will be thrown.
|
|
124
|
+
*
|
|
125
|
+
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import { assertArrayIncludes } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
130
|
+
*
|
|
131
|
+
* assertArrayIncludes<number>([1, 2], [2])
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function assertArrayIncludes<T>(actual: ArrayLike<T>, expected: ArrayLike<T>, msg?: string): void;
|
|
135
|
+
/**
|
|
136
|
+
* Make an assertion that `actual` match RegExp `expected`. If not
|
|
137
|
+
* then throw.
|
|
138
|
+
*/
|
|
139
|
+
export declare function assertMatch(actual: string, expected: RegExp, msg?: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Make an assertion that `actual` not match RegExp `expected`. If match
|
|
142
|
+
* then throw.
|
|
143
|
+
*/
|
|
144
|
+
export declare function assertNotMatch(actual: string, expected: RegExp, msg?: string): void;
|
|
145
|
+
/**
|
|
146
|
+
* Make an assertion that `actual` object is a subset of `expected` object, deeply.
|
|
147
|
+
* If not, then throw.
|
|
148
|
+
*/
|
|
149
|
+
export declare function assertObjectMatch(actual: Record<PropertyKey, any>, expected: Record<PropertyKey, unknown>, msg?: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Forcefully throws a failed assertion
|
|
152
|
+
*/
|
|
153
|
+
export declare function fail(msg?: string): never;
|
|
154
|
+
/**
|
|
155
|
+
* Make an assertion that `error` is an `Error`.
|
|
156
|
+
* If not then an error will be thrown.
|
|
157
|
+
* An error class and a string that should be included in the
|
|
158
|
+
* error message can also be asserted.
|
|
159
|
+
*/
|
|
160
|
+
export declare function assertIsError<E extends Error = Error>(error: unknown, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): asserts error is E;
|
|
161
|
+
/**
|
|
162
|
+
* Executes a function, expecting it to throw. If it does not, then it
|
|
163
|
+
* throws.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
168
|
+
*
|
|
169
|
+
* Deno.test("doesThrow", function (): void {
|
|
170
|
+
* assertThrows((): void => {
|
|
171
|
+
* throw new TypeError("hello world!");
|
|
172
|
+
* });
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* // This test will not pass.
|
|
176
|
+
* Deno.test("fails", function (): void {
|
|
177
|
+
* assertThrows((): void => {
|
|
178
|
+
* console.log("Hello world");
|
|
179
|
+
* });
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function assertThrows(fn: () => unknown, msg?: string): unknown;
|
|
184
|
+
/**
|
|
185
|
+
* Executes a function, expecting it to throw. If it does not, then it
|
|
186
|
+
* throws. An error class and a string that should be included in the
|
|
187
|
+
* error message can also be asserted.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* import { assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
193
|
+
*
|
|
194
|
+
* Deno.test("doesThrow", function (): void {
|
|
195
|
+
* assertThrows((): void => {
|
|
196
|
+
* throw new TypeError("hello world!");
|
|
197
|
+
* }, TypeError);
|
|
198
|
+
* assertThrows(
|
|
199
|
+
* (): void => {
|
|
200
|
+
* throw new TypeError("hello world!");
|
|
201
|
+
* },
|
|
202
|
+
* TypeError,
|
|
203
|
+
* "hello",
|
|
204
|
+
* );
|
|
205
|
+
* });
|
|
206
|
+
*
|
|
207
|
+
* // This test will not pass.
|
|
208
|
+
* Deno.test("fails", function (): void {
|
|
209
|
+
* assertThrows((): void => {
|
|
210
|
+
* console.log("Hello world");
|
|
211
|
+
* });
|
|
212
|
+
* });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function assertThrows<E extends Error = Error>(fn: () => unknown, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): E;
|
|
216
|
+
/**
|
|
217
|
+
* Executes a function which returns a promise, expecting it to reject.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* import { assertRejects } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
222
|
+
*
|
|
223
|
+
* Deno.test("doesThrow", async function () {
|
|
224
|
+
* await assertRejects(
|
|
225
|
+
* async () => {
|
|
226
|
+
* throw new TypeError("hello world!");
|
|
227
|
+
* },
|
|
228
|
+
* );
|
|
229
|
+
* await assertRejects(
|
|
230
|
+
* async () => {
|
|
231
|
+
* return Promise.reject(new Error());
|
|
232
|
+
* },
|
|
233
|
+
* );
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* // This test will not pass.
|
|
237
|
+
* Deno.test("fails", async function () {
|
|
238
|
+
* await assertRejects(
|
|
239
|
+
* async () => {
|
|
240
|
+
* console.log("Hello world");
|
|
241
|
+
* },
|
|
242
|
+
* );
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function assertRejects(fn: () => PromiseLike<unknown>, msg?: string): Promise<unknown>;
|
|
247
|
+
/**
|
|
248
|
+
* Executes a function which returns a promise, expecting it to reject.
|
|
249
|
+
* If it does not, then it throws. An error class and a string that should be
|
|
250
|
+
* included in the error message can also be asserted.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import { assertRejects } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
255
|
+
*
|
|
256
|
+
* Deno.test("doesThrow", async function () {
|
|
257
|
+
* await assertRejects(async () => {
|
|
258
|
+
* throw new TypeError("hello world!");
|
|
259
|
+
* }, TypeError);
|
|
260
|
+
* await assertRejects(
|
|
261
|
+
* async () => {
|
|
262
|
+
* throw new TypeError("hello world!");
|
|
263
|
+
* },
|
|
264
|
+
* TypeError,
|
|
265
|
+
* "hello",
|
|
266
|
+
* );
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* // This test will not pass.
|
|
270
|
+
* Deno.test("fails", async function () {
|
|
271
|
+
* await assertRejects(
|
|
272
|
+
* async () => {
|
|
273
|
+
* console.log("Hello world");
|
|
274
|
+
* },
|
|
275
|
+
* );
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
export declare function assertRejects<E extends Error = Error>(fn: () => PromiseLike<unknown>, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): Promise<E>;
|
|
280
|
+
/** Use this to stub out methods that will throw when invoked. */
|
|
281
|
+
export declare function unimplemented(msg?: string): never;
|
|
282
|
+
/** Use this to assert unreachable code. */
|
|
283
|
+
export declare function unreachable(): never;
|
|
284
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LoaderStateOptions } from "./loader_state.js";
|
|
2
|
+
export type CbFunction = (doc: unknown) => void;
|
|
3
|
+
export declare function loadAll<T extends CbFunction | LoaderStateOptions>(input: string, iteratorOrOption?: T, options?: LoaderStateOptions): T extends CbFunction ? void : unknown[];
|
|
4
|
+
export declare function load(input: string, options?: LoaderStateOptions): unknown;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { YAMLError } from "../_error.js";
|
|
2
|
+
import type { SchemaDefinition, TypeMap } from "../schema.js";
|
|
3
|
+
import { State } from "../_state.js";
|
|
4
|
+
import type { Type } from "../type.js";
|
|
5
|
+
import type { Any, ArrayObject } from "../_utils.js";
|
|
6
|
+
export interface LoaderStateOptions {
|
|
7
|
+
legacy?: boolean;
|
|
8
|
+
listener?: ((...args: Any[]) => void) | null;
|
|
9
|
+
/** string to be used as a file path in error/warning messages. */
|
|
10
|
+
filename?: string;
|
|
11
|
+
/** specifies a schema to use. */
|
|
12
|
+
schema?: SchemaDefinition;
|
|
13
|
+
/** compatibility with JSON.parse behaviour. */
|
|
14
|
+
json?: boolean;
|
|
15
|
+
/** function to call on warning messages. */
|
|
16
|
+
onWarning?(this: null, e?: YAMLError): void;
|
|
17
|
+
}
|
|
18
|
+
export type ResultType = any[] | Record<string, any> | string;
|
|
19
|
+
export declare class LoaderState extends State {
|
|
20
|
+
input: string;
|
|
21
|
+
documents: Any[];
|
|
22
|
+
length: number;
|
|
23
|
+
lineIndent: number;
|
|
24
|
+
lineStart: number;
|
|
25
|
+
position: number;
|
|
26
|
+
line: number;
|
|
27
|
+
filename?: string;
|
|
28
|
+
onWarning?: (...args: Any[]) => void;
|
|
29
|
+
legacy: boolean;
|
|
30
|
+
json: boolean;
|
|
31
|
+
listener?: ((...args: Any[]) => void) | null;
|
|
32
|
+
implicitTypes: Type[];
|
|
33
|
+
typeMap: TypeMap;
|
|
34
|
+
version?: string | null;
|
|
35
|
+
checkLineBreaks?: boolean;
|
|
36
|
+
tagMap?: ArrayObject;
|
|
37
|
+
anchorMap?: ArrayObject;
|
|
38
|
+
tag?: string | null;
|
|
39
|
+
anchor?: string | null;
|
|
40
|
+
kind?: string | null;
|
|
41
|
+
result: ResultType | null;
|
|
42
|
+
constructor(input: string, { filename, schema, onWarning, legacy, json, listener, }: LoaderStateOptions);
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Mark {
|
|
2
|
+
name: string;
|
|
3
|
+
buffer: string;
|
|
4
|
+
position: number;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
constructor(name: string, buffer: string, position: number, line: number, column: number);
|
|
8
|
+
getSnippet(indent?: number, maxLength?: number): string | null;
|
|
9
|
+
toString(compact?: boolean): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { binary } from "./binary.js";
|
|
2
|
+
export { bool } from "./bool.js";
|
|
3
|
+
export { float } from "./float.js";
|
|
4
|
+
export { func } from "./function.js";
|
|
5
|
+
export { int } from "./int.js";
|
|
6
|
+
export { map } from "./map.js";
|
|
7
|
+
export { merge } from "./merge.js";
|
|
8
|
+
export { nil } from "./nil.js";
|
|
9
|
+
export { omap } from "./omap.js";
|
|
10
|
+
export { pairs } from "./pairs.js";
|
|
11
|
+
export { regexp } from "./regexp.js";
|
|
12
|
+
export { seq } from "./seq.js";
|
|
13
|
+
export { set } from "./set.js";
|
|
14
|
+
export { str } from "./str.js";
|
|
15
|
+
export { timestamp } from "./timestamp.js";
|
|
16
|
+
export { undefinedType } from "./undefined.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Any = any;
|
|
2
|
+
export declare function isNothing(subject: unknown): subject is never;
|
|
3
|
+
export declare function isArray(value: unknown): value is Any[];
|
|
4
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
5
|
+
export declare function isNull(value: unknown): value is null;
|
|
6
|
+
export declare function isNumber(value: unknown): value is number;
|
|
7
|
+
export declare function isString(value: unknown): value is string;
|
|
8
|
+
export declare function isSymbol(value: unknown): value is symbol;
|
|
9
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
10
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
11
|
+
export declare function isError(e: unknown): boolean;
|
|
12
|
+
export declare function isFunction(value: unknown): value is () => void;
|
|
13
|
+
export declare function isRegExp(value: unknown): value is RegExp;
|
|
14
|
+
export declare function toArray<T>(sequence: T): T | [] | [T];
|
|
15
|
+
export declare function repeat(str: string, count: number): string;
|
|
16
|
+
export declare function isNegativeZero(i: number): boolean;
|
|
17
|
+
export interface ArrayObject<T = Any> {
|
|
18
|
+
[P: string]: T;
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CbFunction } from "./_loader/loader.js";
|
|
2
|
+
import type { LoaderStateOptions } from "./_loader/loader_state.js";
|
|
3
|
+
export type ParseOptions = LoaderStateOptions;
|
|
4
|
+
/**
|
|
5
|
+
* Parses `content` as single YAML document.
|
|
6
|
+
*
|
|
7
|
+
* Returns a JavaScript object or throws `YAMLError` on error.
|
|
8
|
+
* By default, does not support regexps, functions and undefined. This method is safe for untrusted data.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parse(content: string, options?: ParseOptions): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Same as `parse()`, but understands multi-document sources.
|
|
13
|
+
* Applies iterator to each document if specified, or returns array of documents.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { parseAll } from "https://deno.land/std@$STD_VERSION/yaml/parse.ts";
|
|
18
|
+
*
|
|
19
|
+
* const data = parseAll(`
|
|
20
|
+
* ---
|
|
21
|
+
* id: 1
|
|
22
|
+
* name: Alice
|
|
23
|
+
* ---
|
|
24
|
+
* id: 2
|
|
25
|
+
* name: Bob
|
|
26
|
+
* ---
|
|
27
|
+
* id: 3
|
|
28
|
+
* name: Eve
|
|
29
|
+
* `);
|
|
30
|
+
* console.log(data);
|
|
31
|
+
* // => [ { id: 1, name: "Alice" }, { id: 2, name: "Bob" }, { id: 3, name: "Eve" } ]
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseAll(content: string, iterator: CbFunction, options?: ParseOptions): void;
|
|
35
|
+
export declare function parseAll(content: string, options?: ParseOptions): unknown;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Schema } from "../schema.js";
|
|
2
|
+
/***
|
|
3
|
+
* Extends JS-YAML default schema with additional JavaScript types
|
|
4
|
+
* It is not described in the YAML specification.
|
|
5
|
+
* Functions are no longer supported for security reasons.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import {
|
|
10
|
+
* EXTENDED_SCHEMA,
|
|
11
|
+
* parse,
|
|
12
|
+
* } from "https://deno.land/std@$STD_VERSION/yaml/mod.ts";
|
|
13
|
+
*
|
|
14
|
+
* const data = parse(
|
|
15
|
+
* `
|
|
16
|
+
* regexp:
|
|
17
|
+
* simple: !!js/regexp foobar
|
|
18
|
+
* modifiers: !!js/regexp /foobar/mi
|
|
19
|
+
* undefined: !!js/undefined ~
|
|
20
|
+
* # Disabled, see: https://github.com/denoland/deno_std/pull/1275
|
|
21
|
+
* # function: !!js/function >
|
|
22
|
+
* # function foobar() {
|
|
23
|
+
* # return 'hello world!';
|
|
24
|
+
* # }
|
|
25
|
+
* `,
|
|
26
|
+
* { schema: EXTENDED_SCHEMA },
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const extended: Schema;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { core as CORE_SCHEMA } from "./core.js";
|
|
2
|
+
export { def as DEFAULT_SCHEMA } from "./default.js";
|
|
3
|
+
export { extended as EXTENDED_SCHEMA } from "./extended.js";
|
|
4
|
+
export { failsafe as FAILSAFE_SCHEMA } from "./failsafe.js";
|
|
5
|
+
export { json as JSON_SCHEMA } from "./json.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { KindType, Type } from "./type.js";
|
|
2
|
+
import type { Any, ArrayObject } from "./_utils.js";
|
|
3
|
+
export type TypeMap = {
|
|
4
|
+
[k in KindType | "fallback"]: ArrayObject<Type>;
|
|
5
|
+
};
|
|
6
|
+
export declare class Schema implements SchemaDefinition {
|
|
7
|
+
static SCHEMA_DEFAULT?: Schema;
|
|
8
|
+
implicit: Type[];
|
|
9
|
+
explicit: Type[];
|
|
10
|
+
include: Schema[];
|
|
11
|
+
compiledImplicit: Type[];
|
|
12
|
+
compiledExplicit: Type[];
|
|
13
|
+
compiledTypeMap: TypeMap;
|
|
14
|
+
constructor(definition: SchemaDefinition);
|
|
15
|
+
extend(definition: SchemaDefinition): Schema;
|
|
16
|
+
static create(): void;
|
|
17
|
+
}
|
|
18
|
+
export interface SchemaDefinition {
|
|
19
|
+
implicit?: Any[];
|
|
20
|
+
explicit?: Type[];
|
|
21
|
+
include?: Schema[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Any, ArrayObject } from "./_utils.js";
|
|
2
|
+
export type KindType = "sequence" | "scalar" | "mapping";
|
|
3
|
+
export type StyleVariant = "lowercase" | "uppercase" | "camelcase" | "decimal";
|
|
4
|
+
export type RepresentFn = (data: Any, style?: StyleVariant) => Any;
|
|
5
|
+
interface TypeOptions {
|
|
6
|
+
kind: KindType;
|
|
7
|
+
resolve?: (data: Any) => boolean;
|
|
8
|
+
construct?: (data: string) => Any;
|
|
9
|
+
instanceOf?: Any;
|
|
10
|
+
predicate?: (data: Record<string, unknown>) => boolean;
|
|
11
|
+
represent?: RepresentFn | ArrayObject<RepresentFn>;
|
|
12
|
+
defaultStyle?: StyleVariant;
|
|
13
|
+
styleAliases?: ArrayObject;
|
|
14
|
+
}
|
|
15
|
+
export declare class Type {
|
|
16
|
+
tag: string;
|
|
17
|
+
kind: KindType | null;
|
|
18
|
+
instanceOf: Any;
|
|
19
|
+
predicate?: (data: Record<string, unknown>) => boolean;
|
|
20
|
+
represent?: RepresentFn | ArrayObject<RepresentFn>;
|
|
21
|
+
defaultStyle?: StyleVariant;
|
|
22
|
+
styleAliases?: ArrayObject;
|
|
23
|
+
loadKind?: KindType;
|
|
24
|
+
constructor(tag: string, options?: TypeOptions);
|
|
25
|
+
resolve: (data?: Any) => boolean;
|
|
26
|
+
construct: (data?: Any) => Any;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/esm/deps.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as path from "./deps/deno.land/std@0.178.0/path/mod.js";
|
package/esm/deps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as path from "./deps/deno.land/std@0.178.0/path/mod.js";
|
package/esm/mod.d.ts
ADDED
package/esm/mod.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as dntShim from "./_dnt.shims.js";
|
|
2
|
+
import { Environment } from "./src/environment.js";
|
|
3
|
+
import { FileLoader } from "./src/loader.js";
|
|
4
|
+
import ifTag from "./plugins/if.js";
|
|
5
|
+
import forTag from "./plugins/for.js";
|
|
6
|
+
import includeTag from "./plugins/include.js";
|
|
7
|
+
import setTag from "./plugins/set.js";
|
|
8
|
+
import jsTag from "./plugins/js.js";
|
|
9
|
+
import layoutTag from "./plugins/layout.js";
|
|
10
|
+
import escape from "./plugins/escape.js";
|
|
11
|
+
export default function (options = {}) {
|
|
12
|
+
const loader = typeof options.includes === "object"
|
|
13
|
+
? options.includes
|
|
14
|
+
: new FileLoader(options.includes || dntShim.Deno.cwd());
|
|
15
|
+
const env = new Environment({
|
|
16
|
+
loader,
|
|
17
|
+
dataVarname: options.dataVarname || "it",
|
|
18
|
+
});
|
|
19
|
+
// Register basic plugins
|
|
20
|
+
env.use(ifTag());
|
|
21
|
+
env.use(forTag());
|
|
22
|
+
env.use(jsTag());
|
|
23
|
+
env.use(includeTag());
|
|
24
|
+
env.use(setTag());
|
|
25
|
+
env.use(layoutTag());
|
|
26
|
+
env.use(escape());
|
|
27
|
+
return env;
|
|
28
|
+
}
|
package/esm/package.json
ADDED