@cloudpss/yaml 0.4.13 → 0.4.14
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/coverage/clover.xml +124 -0
- package/coverage/coverage-final.json +3 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/index.ts.html +157 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/schema.js.html +349 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +179 -0
- package/dist/schema.js +52 -18
- package/dist/schema.js.map +1 -1
- package/jest.config.js +3 -0
- package/package.json +3 -2
- package/src/schema.js +48 -16
- package/tests/__snapshots__/types.js.snap +199 -0
- package/tests/types.js +76 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ArrayBuffer should be dumped as base64 1`] = `
|
|
4
|
+
"!!js/ArrayBuffer PyvVdTF6oNc=
|
|
5
|
+
"
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
exports[`TypedArray should be dumped as array Float32Array 1`] = `
|
|
9
|
+
"!!js/Float32Array
|
|
10
|
+
- 5.4044744426519224e+32
|
|
11
|
+
- -352893337075712
|
|
12
|
+
"
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`TypedArray should be dumped as array Float64Array 1`] = `
|
|
16
|
+
"!!js/Float64Array
|
|
17
|
+
- -1.2680456144014297e+114
|
|
18
|
+
"
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`TypedArray should be dumped as array Int8Array 1`] = `
|
|
22
|
+
"!!js/Int8Array
|
|
23
|
+
- 63
|
|
24
|
+
- 43
|
|
25
|
+
- -43
|
|
26
|
+
- 117
|
|
27
|
+
- 49
|
|
28
|
+
- 122
|
|
29
|
+
- -96
|
|
30
|
+
- -41
|
|
31
|
+
"
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
exports[`TypedArray should be dumped as array Int16Array 1`] = `
|
|
35
|
+
"!!js/Int16Array
|
|
36
|
+
- 11071
|
|
37
|
+
- 30165
|
|
38
|
+
- 31281
|
|
39
|
+
- -10336
|
|
40
|
+
"
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`TypedArray should be dumped as array Int32Array 1`] = `
|
|
44
|
+
"!!js/Int32Array
|
|
45
|
+
- 1976904511
|
|
46
|
+
- -677348815
|
|
47
|
+
"
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
exports[`TypedArray should be dumped as array Uint8Array 1`] = `
|
|
51
|
+
"!!js/Uint8Array
|
|
52
|
+
- 63
|
|
53
|
+
- 43
|
|
54
|
+
- 213
|
|
55
|
+
- 117
|
|
56
|
+
- 49
|
|
57
|
+
- 122
|
|
58
|
+
- 160
|
|
59
|
+
- 215
|
|
60
|
+
"
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
exports[`TypedArray should be dumped as array Uint8ClampedArray 1`] = `
|
|
64
|
+
"!!js/Uint8ClampedArray
|
|
65
|
+
- 63
|
|
66
|
+
- 43
|
|
67
|
+
- 213
|
|
68
|
+
- 117
|
|
69
|
+
- 49
|
|
70
|
+
- 122
|
|
71
|
+
- 160
|
|
72
|
+
- 215
|
|
73
|
+
"
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
exports[`TypedArray should be dumped as array Uint16Array 1`] = `
|
|
77
|
+
"!!js/Uint16Array
|
|
78
|
+
- 11071
|
|
79
|
+
- 30165
|
|
80
|
+
- 31281
|
|
81
|
+
- 55200
|
|
82
|
+
"
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
exports[`TypedArray should be dumped as array Uint32Array 1`] = `
|
|
86
|
+
"!!js/Uint32Array
|
|
87
|
+
- 1976904511
|
|
88
|
+
- 3617618481
|
|
89
|
+
"
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
exports[`TypedArray should be dumped as base64 Float32Array 1`] = `
|
|
93
|
+
"!!js/Float32Array PyvVdTF6oNc=
|
|
94
|
+
"
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
exports[`TypedArray should be dumped as base64 Float64Array 1`] = `
|
|
98
|
+
"!!js/Float64Array PyvVdTF6oNc=
|
|
99
|
+
"
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
exports[`TypedArray should be dumped as base64 Int8Array 1`] = `
|
|
103
|
+
"!!js/Int8Array PyvVdTF6oNc=
|
|
104
|
+
"
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
exports[`TypedArray should be dumped as base64 Int16Array 1`] = `
|
|
108
|
+
"!!js/Int16Array PyvVdTF6oNc=
|
|
109
|
+
"
|
|
110
|
+
`;
|
|
111
|
+
|
|
112
|
+
exports[`TypedArray should be dumped as base64 Int32Array 1`] = `
|
|
113
|
+
"!!js/Int32Array PyvVdTF6oNc=
|
|
114
|
+
"
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
exports[`TypedArray should be dumped as base64 Uint8Array 1`] = `
|
|
118
|
+
"!!js/Uint8Array PyvVdTF6oNc=
|
|
119
|
+
"
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
exports[`TypedArray should be dumped as base64 Uint8ClampedArray 1`] = `
|
|
123
|
+
"!!js/Uint8ClampedArray PyvVdTF6oNc=
|
|
124
|
+
"
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`TypedArray should be dumped as base64 Uint16Array 1`] = `
|
|
128
|
+
"!!js/Uint16Array PyvVdTF6oNc=
|
|
129
|
+
"
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
exports[`TypedArray should be dumped as base64 Uint32Array 1`] = `
|
|
133
|
+
"!!js/Uint32Array PyvVdTF6oNc=
|
|
134
|
+
"
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
exports[`TypedArray should be dumped as base64 by default Float32Array 1`] = `
|
|
138
|
+
"!!js/Float32Array PyvVdTF6oNc=
|
|
139
|
+
"
|
|
140
|
+
`;
|
|
141
|
+
|
|
142
|
+
exports[`TypedArray should be dumped as base64 by default Float64Array 1`] = `
|
|
143
|
+
"!!js/Float64Array PyvVdTF6oNc=
|
|
144
|
+
"
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
exports[`TypedArray should be dumped as base64 by default Int8Array 1`] = `
|
|
148
|
+
"!!js/Int8Array PyvVdTF6oNc=
|
|
149
|
+
"
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
exports[`TypedArray should be dumped as base64 by default Int16Array 1`] = `
|
|
153
|
+
"!!js/Int16Array PyvVdTF6oNc=
|
|
154
|
+
"
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
exports[`TypedArray should be dumped as base64 by default Int32Array 1`] = `
|
|
158
|
+
"!!js/Int32Array PyvVdTF6oNc=
|
|
159
|
+
"
|
|
160
|
+
`;
|
|
161
|
+
|
|
162
|
+
exports[`TypedArray should be dumped as base64 by default Uint8Array 1`] = `
|
|
163
|
+
"!!js/Uint8Array PyvVdTF6oNc=
|
|
164
|
+
"
|
|
165
|
+
`;
|
|
166
|
+
|
|
167
|
+
exports[`TypedArray should be dumped as base64 by default Uint8ClampedArray 1`] = `
|
|
168
|
+
"!!js/Uint8ClampedArray PyvVdTF6oNc=
|
|
169
|
+
"
|
|
170
|
+
`;
|
|
171
|
+
|
|
172
|
+
exports[`TypedArray should be dumped as base64 by default Uint16Array 1`] = `
|
|
173
|
+
"!!js/Uint16Array PyvVdTF6oNc=
|
|
174
|
+
"
|
|
175
|
+
`;
|
|
176
|
+
|
|
177
|
+
exports[`TypedArray should be dumped as base64 by default Uint32Array 1`] = `
|
|
178
|
+
"!!js/Uint32Array PyvVdTF6oNc=
|
|
179
|
+
"
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
exports[`map should be dumped as pair sequence 1`] = `
|
|
183
|
+
"!!js/map
|
|
184
|
+
- - a
|
|
185
|
+
- 1
|
|
186
|
+
- - b
|
|
187
|
+
- c: 2
|
|
188
|
+
- - d: 3
|
|
189
|
+
- e
|
|
190
|
+
"
|
|
191
|
+
`;
|
|
192
|
+
|
|
193
|
+
exports[`set should be dumped as sequence 1`] = `
|
|
194
|
+
"!!js/set
|
|
195
|
+
- a
|
|
196
|
+
- b
|
|
197
|
+
- c: 1
|
|
198
|
+
"
|
|
199
|
+
`;
|
package/tests/types.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { dump, load } from '@cloudpss/yaml';
|
|
2
|
+
|
|
3
|
+
const TypedArrays = [
|
|
4
|
+
Float32Array,
|
|
5
|
+
Float64Array,
|
|
6
|
+
Uint8Array,
|
|
7
|
+
Uint8ClampedArray,
|
|
8
|
+
Uint16Array,
|
|
9
|
+
Uint32Array,
|
|
10
|
+
Int8Array,
|
|
11
|
+
Int16Array,
|
|
12
|
+
Int32Array,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
it('ArrayBuffer should be dumped as base64', () => {
|
|
16
|
+
const data = new Uint8Array([63, 43, 213, 117, 49, 122, 160, 215]);
|
|
17
|
+
const dumped = dump(data.buffer);
|
|
18
|
+
expect(dumped).toMatchSnapshot();
|
|
19
|
+
expect(new Uint8Array(/** @type {ArrayBuffer} */ (load(dumped)))).toEqual(data);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('TypedArray should be dumped as base64 by default', () => {
|
|
23
|
+
for (const type of TypedArrays) {
|
|
24
|
+
it(type.name, () => {
|
|
25
|
+
const buffer = new Uint8Array([63, 43, 213, 117, 49, 122, 160, 215]).buffer;
|
|
26
|
+
const data = new type(buffer);
|
|
27
|
+
const dumped = dump(data);
|
|
28
|
+
expect(dumped).toMatchSnapshot();
|
|
29
|
+
expect(load(dumped)).toEqual(data);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('TypedArray should be dumped as base64', () => {
|
|
35
|
+
for (const type of TypedArrays) {
|
|
36
|
+
it(type.name, () => {
|
|
37
|
+
const buffer = new Uint8Array([63, 43, 213, 117, 49, 122, 160, 215]).buffer;
|
|
38
|
+
const data = new type(buffer);
|
|
39
|
+
const dumped = dump(data, { styles: { [`!!js/${type.name}`]: 'base64' } });
|
|
40
|
+
expect(dumped).toMatchSnapshot();
|
|
41
|
+
expect(load(dumped)).toEqual(data);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('TypedArray should be dumped as array', () => {
|
|
47
|
+
for (const type of TypedArrays) {
|
|
48
|
+
it(type.name, () => {
|
|
49
|
+
const buffer = new Uint8Array([63, 43, 213, 117, 49, 122, 160, 215]).buffer;
|
|
50
|
+
const data = new type(buffer);
|
|
51
|
+
const dumped = dump(data, { styles: { [`!!js/${type.name}`]: 'sequence' } });
|
|
52
|
+
expect(dumped).toMatchSnapshot();
|
|
53
|
+
expect(load(dumped)).toEqual(data);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('map should be dumped as pair sequence', () => {
|
|
59
|
+
const data = new Map(
|
|
60
|
+
/** @type {Array<[unknown, unknown]>} */ ([
|
|
61
|
+
['a', 1],
|
|
62
|
+
['b', { c: 2 }],
|
|
63
|
+
[{ d: 3 }, 'e'],
|
|
64
|
+
]),
|
|
65
|
+
);
|
|
66
|
+
const dumped = dump(data);
|
|
67
|
+
expect(dumped).toMatchSnapshot();
|
|
68
|
+
expect(load(dumped)).toEqual(data);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('set should be dumped as sequence', () => {
|
|
72
|
+
const data = new Set(['a', 'b', { c: 1 }]);
|
|
73
|
+
const dumped = dump(data);
|
|
74
|
+
expect(dumped).toMatchSnapshot();
|
|
75
|
+
expect(load(dumped)).toEqual(data);
|
|
76
|
+
});
|