fastyaml-rs 0.1.4 → 0.1.6
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/index.d.ts +129 -83
- package/index.js +531 -196
- package/package.json +6 -14
- package/.prettierignore +0 -7
- package/.prettierrc.json +0 -10
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -101
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -101
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -0
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/fast-yaml.darwin-arm64.node +0 -0
package/index.d.ts
CHANGED
|
@@ -1,126 +1,172 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* This module provides high-performance YAML parsing and serialization
|
|
5
|
-
* with 5-10x speedup over pure JavaScript implementations.
|
|
6
|
-
*
|
|
7
|
-
* @module @fast-yaml/core
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Options for YAML serialization.
|
|
12
|
-
*/
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** Options for YAML serialization. */
|
|
13
4
|
export interface DumpOptions {
|
|
5
|
+
/** If true, sort object keys alphabetically (default: false) */
|
|
6
|
+
sortKeys?: boolean
|
|
14
7
|
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
sortKeys?: boolean;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Allow unicode characters (default: true)
|
|
21
|
-
* Note: yaml-rust2 always outputs unicode; this is accepted for API compatibility
|
|
8
|
+
* Allow unicode characters (default: true).
|
|
9
|
+
* Note: yaml-rust2 always outputs unicode; this is accepted for API compatibility.
|
|
22
10
|
*/
|
|
23
|
-
allowUnicode?: boolean
|
|
11
|
+
allowUnicode?: boolean
|
|
24
12
|
}
|
|
25
13
|
|
|
26
14
|
/**
|
|
27
|
-
*
|
|
28
|
-
* Equivalent to js-yaml's `safeLoad()`.
|
|
15
|
+
* Serialize a JavaScript object to a YAML string.
|
|
29
16
|
*
|
|
30
|
-
*
|
|
31
|
-
* @returns Parsed JavaScript object
|
|
32
|
-
* @throws {Error} If YAML is invalid or exceeds 100MB limit
|
|
17
|
+
* This is equivalent to js-yaml's `safeDump()` and `PyYAML`'s `safe_dump()`.
|
|
33
18
|
*
|
|
34
|
-
*
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import { safeLoad } from '@fast-yaml/core';
|
|
19
|
+
* # Arguments
|
|
37
20
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
21
|
+
* * `data` - A JavaScript object to serialize (Object, Array, string, number, boolean, null)
|
|
22
|
+
* * `options` - Optional serialization options
|
|
23
|
+
*
|
|
24
|
+
* # Returns
|
|
25
|
+
*
|
|
26
|
+
* A YAML string representation of the object
|
|
27
|
+
*
|
|
28
|
+
* # Errors
|
|
29
|
+
*
|
|
30
|
+
* Throws an error if the object contains non-serializable types.
|
|
31
|
+
*
|
|
32
|
+
* # Example
|
|
33
|
+
*
|
|
34
|
+
* ```javascript
|
|
35
|
+
* const { safeDump } = require('@fast-yaml/core');
|
|
36
|
+
*
|
|
37
|
+
* const yaml = safeDump({ name: 'test', value: 123 });
|
|
38
|
+
* console.log(yaml); // 'name: test
|
|
39
|
+
value: 123
|
|
40
|
+
'
|
|
40
41
|
* ```
|
|
41
42
|
*/
|
|
42
|
-
export function
|
|
43
|
+
export declare function safeDump(data: unknown, options?: DumpOptions | undefined | null): NapiResult<string>
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
-
* Equivalent to js-yaml's `safeLoadAll()`.
|
|
46
|
+
* Serialize multiple JavaScript objects to a YAML string with document separators.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* @returns Array of parsed JavaScript objects
|
|
50
|
-
* @throws {Error} If YAML is invalid or exceeds 100MB limit
|
|
48
|
+
* This is equivalent to js-yaml's `safeDumpAll()` and `PyYAML`'s `safe_dump_all()`.
|
|
51
49
|
*
|
|
52
|
-
*
|
|
53
|
-
* ```typescript
|
|
54
|
-
* import { safeLoadAll } from '@fast-yaml/core';
|
|
50
|
+
* # Arguments
|
|
55
51
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
52
|
+
* * `documents` - An array of JavaScript objects to serialize
|
|
53
|
+
* * `options` - Optional serialization options
|
|
54
|
+
*
|
|
55
|
+
* # Returns
|
|
56
|
+
*
|
|
57
|
+
* A YAML string with multiple documents separated by "---"
|
|
58
|
+
*
|
|
59
|
+
* # Errors
|
|
60
|
+
*
|
|
61
|
+
* Throws an error if:
|
|
62
|
+
* - Any object cannot be serialized
|
|
63
|
+
* - Total output size exceeds 100MB limit
|
|
64
|
+
*
|
|
65
|
+
* # Security
|
|
66
|
+
*
|
|
67
|
+
* Maximum output size is limited to 100MB to prevent memory exhaustion.
|
|
68
|
+
*
|
|
69
|
+
* # Example
|
|
70
|
+
*
|
|
71
|
+
* ```javascript
|
|
72
|
+
* const { safeDumpAll } = require('@fast-yaml/core');
|
|
73
|
+
*
|
|
74
|
+
* const yaml = safeDumpAll([{ a: 1 }, { b: 2 }]);
|
|
75
|
+
* console.log(yaml); // '---
|
|
76
|
+
a: 1
|
|
77
|
+
---
|
|
78
|
+
b: 2
|
|
79
|
+
'
|
|
58
80
|
* ```
|
|
59
81
|
*/
|
|
60
|
-
export function
|
|
82
|
+
export declare function safeDumpAll(documents: Array<unknown>, options?: DumpOptions | undefined | null): NapiResult<string>
|
|
61
83
|
|
|
62
84
|
/**
|
|
63
|
-
*
|
|
64
|
-
* Equivalent to js-yaml's `safeDump()`.
|
|
85
|
+
* Parse a YAML string and return a JavaScript object.
|
|
65
86
|
*
|
|
66
|
-
*
|
|
67
|
-
* @param options - Serialization options
|
|
68
|
-
* @returns YAML string representation
|
|
69
|
-
* @throws {TypeError} If object contains non-serializable types
|
|
87
|
+
* This is equivalent to js-yaml's `safeLoad()` and `PyYAML`'s `safe_load()`.
|
|
70
88
|
*
|
|
71
|
-
*
|
|
72
|
-
* ```typescript
|
|
73
|
-
* import { safeDump } from '@fast-yaml/core';
|
|
89
|
+
* # Arguments
|
|
74
90
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
91
|
+
* * `yaml_str` - A YAML document as a string
|
|
92
|
+
*
|
|
93
|
+
* # Returns
|
|
94
|
+
*
|
|
95
|
+
* The parsed YAML document as JavaScript objects (Object, Array, string, number, boolean, null)
|
|
96
|
+
*
|
|
97
|
+
* # Errors
|
|
98
|
+
*
|
|
99
|
+
* Throws an error if:
|
|
100
|
+
* - The YAML is invalid
|
|
101
|
+
* - Input exceeds size limit (100MB)
|
|
102
|
+
*
|
|
103
|
+
* # Security
|
|
104
|
+
*
|
|
105
|
+
* Maximum input size is limited to 100MB to prevent denial-of-service attacks.
|
|
106
|
+
*
|
|
107
|
+
* # Example
|
|
108
|
+
*
|
|
109
|
+
* ```javascript
|
|
110
|
+
* const { safeLoad } = require('@fast-yaml/core');
|
|
111
|
+
*
|
|
112
|
+
* const data = safeLoad('name: test
|
|
113
|
+
value: 123');
|
|
114
|
+
* console.log(data); // { name: 'test', value: 123 }
|
|
77
115
|
* ```
|
|
78
116
|
*/
|
|
79
|
-
export function
|
|
117
|
+
export declare function safeLoad(yamlStr: string): NapiResult<unknown>
|
|
80
118
|
|
|
81
119
|
/**
|
|
82
|
-
*
|
|
83
|
-
* Equivalent to js-yaml's `safeDumpAll()`.
|
|
120
|
+
* Parse a YAML string containing multiple documents.
|
|
84
121
|
*
|
|
85
|
-
*
|
|
86
|
-
* @param options - Serialization options
|
|
87
|
-
* @returns YAML string with '---' separators
|
|
88
|
-
* @throws {TypeError} If any object cannot be serialized
|
|
89
|
-
* @throws {Error} If output exceeds 100MB limit
|
|
122
|
+
* This is equivalent to js-yaml's `safeLoadAll()` and `PyYAML`'s `safe_load_all()`.
|
|
90
123
|
*
|
|
91
|
-
*
|
|
92
|
-
* ```typescript
|
|
93
|
-
* import { safeDumpAll } from '@fast-yaml/core';
|
|
124
|
+
* # Arguments
|
|
94
125
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
126
|
+
* * `yaml_str` - A YAML string potentially containing multiple documents
|
|
127
|
+
*
|
|
128
|
+
* # Returns
|
|
129
|
+
*
|
|
130
|
+
* An array of parsed JavaScript objects
|
|
131
|
+
*
|
|
132
|
+
* # Errors
|
|
133
|
+
*
|
|
134
|
+
* Throws an error if:
|
|
135
|
+
* - The YAML is invalid
|
|
136
|
+
* - Input exceeds size limit (100MB)
|
|
137
|
+
*
|
|
138
|
+
* # Security
|
|
139
|
+
*
|
|
140
|
+
* Maximum input size is limited to 100MB to prevent denial-of-service attacks.
|
|
141
|
+
*
|
|
142
|
+
* # Example
|
|
143
|
+
*
|
|
144
|
+
* ```javascript
|
|
145
|
+
* const { safeLoadAll } = require('@fast-yaml/core');
|
|
146
|
+
*
|
|
147
|
+
* const docs = safeLoadAll('---
|
|
148
|
+
foo: 1
|
|
149
|
+
---
|
|
150
|
+
bar: 2');
|
|
151
|
+
* console.log(docs); // [{ foo: 1 }, { bar: 2 }]
|
|
97
152
|
* ```
|
|
98
153
|
*/
|
|
99
|
-
export function
|
|
154
|
+
export declare function safeLoadAll(yamlStr: string): NapiResult<Array<unknown>>
|
|
100
155
|
|
|
101
156
|
/**
|
|
102
157
|
* Get the library version.
|
|
103
158
|
*
|
|
104
|
-
*
|
|
159
|
+
* Returns the version string of the fast-yaml-nodejs crate.
|
|
105
160
|
*
|
|
106
|
-
*
|
|
107
|
-
* ```typescript
|
|
108
|
-
* import { version } from '@fast-yaml/core';
|
|
161
|
+
* # Examples
|
|
109
162
|
*
|
|
163
|
+
* ```javascript
|
|
164
|
+
* const { version } = require('@fast-yaml/core');
|
|
110
165
|
* console.log(version()); // "0.1.0"
|
|
111
166
|
* ```
|
|
112
167
|
*/
|
|
113
|
-
export function version(): string
|
|
168
|
+
export declare function version(): string
|
|
114
169
|
|
|
115
170
|
// Aliases for js-yaml compatibility
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
* @deprecated Use safeLoad() instead
|
|
119
|
-
*/
|
|
120
|
-
export { safeLoad as load };
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Alias for safeDump() for js-yaml compatibility.
|
|
124
|
-
* @deprecated Use safeDump() instead
|
|
125
|
-
*/
|
|
126
|
-
export { safeDump as dump };
|
|
171
|
+
export declare const load: typeof safeLoad
|
|
172
|
+
export declare const dump: typeof safeDump
|