@speclynx/apidom-datamodel 3.2.1 → 4.0.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/CHANGELOG.md +4 -0
- package/package.json +3 -3
- package/src/KeyValuePair.cjs +0 -31
- package/src/KeyValuePair.mjs +0 -27
- package/src/Metadata.cjs +0 -91
- package/src/Metadata.mjs +0 -87
- package/src/Namespace.cjs +0 -212
- package/src/Namespace.mjs +0 -206
- package/src/ObjectSlice.cjs +0 -199
- package/src/ObjectSlice.mjs +0 -195
- package/src/clone/errors/CloneError.cjs +0 -22
- package/src/clone/errors/CloneError.mjs +0 -19
- package/src/clone/errors/DeepCloneError.cjs +0 -11
- package/src/clone/errors/DeepCloneError.mjs +0 -6
- package/src/clone/errors/ShallowCloneError.cjs +0 -11
- package/src/clone/errors/ShallowCloneError.mjs +0 -6
- package/src/clone/index.cjs +0 -188
- package/src/clone/index.mjs +0 -178
- package/src/elements/Annotation.cjs +0 -35
- package/src/elements/Annotation.mjs +0 -30
- package/src/elements/Comment.cjs +0 -18
- package/src/elements/Comment.mjs +0 -13
- package/src/elements/LinkElement.cjs +0 -50
- package/src/elements/LinkElement.mjs +0 -45
- package/src/elements/ParseResult.cjs +0 -91
- package/src/elements/ParseResult.mjs +0 -86
- package/src/elements/RefElement.cjs +0 -34
- package/src/elements/RefElement.mjs +0 -29
- package/src/elements/SourceMap.cjs +0 -140
- package/src/elements/SourceMap.mjs +0 -134
- package/src/elements/Style.cjs +0 -54
- package/src/elements/Style.mjs +0 -48
- package/src/index.cjs +0 -58
- package/src/index.mjs +0 -11
- package/src/predicates/elements.cjs +0 -46
- package/src/predicates/elements.mjs +0 -35
- package/src/predicates/index.cjs +0 -77
- package/src/predicates/index.mjs +0 -56
- package/src/predicates/primitives.cjs +0 -69
- package/src/predicates/primitives.mjs +0 -56
- package/src/primitives/ArrayElement.cjs +0 -155
- package/src/primitives/ArrayElement.mjs +0 -148
- package/src/primitives/BooleanElement.cjs +0 -20
- package/src/primitives/BooleanElement.mjs +0 -15
- package/src/primitives/CollectionElement.cjs +0 -180
- package/src/primitives/CollectionElement.mjs +0 -173
- package/src/primitives/Element.cjs +0 -510
- package/src/primitives/Element.mjs +0 -505
- package/src/primitives/MemberElement.cjs +0 -58
- package/src/primitives/MemberElement.mjs +0 -53
- package/src/primitives/NullElement.cjs +0 -28
- package/src/primitives/NullElement.mjs +0 -23
- package/src/primitives/NumberElement.cjs +0 -20
- package/src/primitives/NumberElement.mjs +0 -15
- package/src/primitives/ObjectElement.cjs +0 -220
- package/src/primitives/ObjectElement.mjs +0 -214
- package/src/primitives/StringElement.cjs +0 -27
- package/src/primitives/StringElement.mjs +0 -22
- package/src/registration.cjs +0 -101
- package/src/registration.mjs +0 -79
- package/src/serialisers/JSONSerialiser.cjs +0 -230
- package/src/serialisers/JSONSerialiser.mjs +0 -221
- package/src/types.cjs +0 -3
- package/src/types.mjs +0 -1
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _SourceMap = _interopRequireDefault(require("../elements/SourceMap.cjs"));
|
|
7
|
-
var _Style = _interopRequireDefault(require("../elements/Style.cjs"));
|
|
8
|
-
/**
|
|
9
|
-
* Serialized representation of an Element in JSON Refract format.
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Serialized representation of a KeyValuePair in JSON Refract format.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Possible content types in a serialized element.
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Input document format for deserialization.
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* JSONSerialiser handles serialization and deserialization of ApiDOM elements
|
|
30
|
-
* to and from JSON Refract format.
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
class JSONSerialiser {
|
|
34
|
-
namespace;
|
|
35
|
-
|
|
36
|
-
// This will be set via prototype assignment to avoid circular dependency
|
|
37
|
-
|
|
38
|
-
constructor(namespace) {
|
|
39
|
-
this.namespace = namespace || new this.Namespace();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Serializes an Element to JSON Refract format.
|
|
44
|
-
*/
|
|
45
|
-
serialise(element) {
|
|
46
|
-
if (!(element instanceof this.namespace.elements.Element)) {
|
|
47
|
-
throw new TypeError(`Given element \`${element}\` is not an Element instance`);
|
|
48
|
-
}
|
|
49
|
-
const payload = {
|
|
50
|
-
element: element.element
|
|
51
|
-
};
|
|
52
|
-
if (!element.isMetaEmpty) {
|
|
53
|
-
const serialisedMeta = this.serialiseMeta(element);
|
|
54
|
-
if (serialisedMeta) {
|
|
55
|
-
payload.meta = serialisedMeta.meta;
|
|
56
|
-
if (serialisedMeta.rawKeys.length > 0) {
|
|
57
|
-
payload.__meta_raw__ = serialisedMeta.rawKeys;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (!element.isAttributesEmpty) {
|
|
62
|
-
payload.attributes = this.serialiseObject(element.attributes);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Serialize source position as __mappings__ in meta (skip for SourceMapElement itself)
|
|
66
|
-
if (!(element instanceof _SourceMap.default)) {
|
|
67
|
-
const sourceMap = _SourceMap.default.from(element);
|
|
68
|
-
if (sourceMap) {
|
|
69
|
-
if (!payload.meta) {
|
|
70
|
-
payload.meta = {};
|
|
71
|
-
}
|
|
72
|
-
payload.meta.__mappings__ = this.serialise(sourceMap);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Serialize style as __styles__ in meta (skip for StyleElement itself)
|
|
77
|
-
if (!(element instanceof _Style.default)) {
|
|
78
|
-
const styleElement = _Style.default.from(element);
|
|
79
|
-
if (styleElement) {
|
|
80
|
-
if (!payload.meta) {
|
|
81
|
-
payload.meta = {};
|
|
82
|
-
}
|
|
83
|
-
payload.meta.__styles__ = this.serialise(styleElement);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const content = this.serialiseContent(element.content);
|
|
87
|
-
if (content !== undefined) {
|
|
88
|
-
payload.content = content;
|
|
89
|
-
}
|
|
90
|
-
return payload;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Deserializes a JSON Refract document to an Element.
|
|
95
|
-
*/
|
|
96
|
-
deserialise(value) {
|
|
97
|
-
if (!value.element) {
|
|
98
|
-
throw new Error('Given value is not an object containing an element name');
|
|
99
|
-
}
|
|
100
|
-
const ElementClass = this.namespace.getElementClass(value.element);
|
|
101
|
-
const element = new ElementClass();
|
|
102
|
-
if (element.element !== value.element) {
|
|
103
|
-
element.element = value.element;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Extract special meta keys without mutating input, filter remaining meta
|
|
107
|
-
let mappingsDoc;
|
|
108
|
-
let stylesDoc;
|
|
109
|
-
let metaToDeserialize = value.meta;
|
|
110
|
-
if (value.meta?.__mappings__ || value.meta?.__styles__) {
|
|
111
|
-
const {
|
|
112
|
-
__mappings__,
|
|
113
|
-
__styles__,
|
|
114
|
-
...rest
|
|
115
|
-
} = value.meta;
|
|
116
|
-
mappingsDoc = __mappings__;
|
|
117
|
-
stylesDoc = __styles__;
|
|
118
|
-
metaToDeserialize = Object.keys(rest).length > 0 ? rest : undefined;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// determine which meta keys were raw primitives before serialization
|
|
122
|
-
const rawKeys = value.__meta_raw__ ? new Set(value.__meta_raw__) : undefined;
|
|
123
|
-
if (metaToDeserialize) {
|
|
124
|
-
for (const [key, doc] of Object.entries(metaToDeserialize)) {
|
|
125
|
-
const deserialized = this.deserialise(doc);
|
|
126
|
-
// unwrap keys that were raw primitives before serialization
|
|
127
|
-
element.setMetaProperty(key, rawKeys?.has(key) ? deserialized.toValue() : deserialized);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Restore source position from __mappings__
|
|
132
|
-
if (mappingsDoc) {
|
|
133
|
-
const sourceMap = this.deserialise(mappingsDoc);
|
|
134
|
-
sourceMap.applyTo(element);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Restore style from __styles__
|
|
138
|
-
if (stylesDoc) {
|
|
139
|
-
const styleElement = this.deserialise(stylesDoc);
|
|
140
|
-
styleElement.applyTo(element);
|
|
141
|
-
}
|
|
142
|
-
if (value.attributes) {
|
|
143
|
-
this.deserialiseObject(value.attributes, element.attributes);
|
|
144
|
-
}
|
|
145
|
-
const content = this.deserialiseContent(value.content);
|
|
146
|
-
if (content !== undefined || element.content === null) {
|
|
147
|
-
element.content = content;
|
|
148
|
-
}
|
|
149
|
-
return element;
|
|
150
|
-
}
|
|
151
|
-
serialiseContent(content) {
|
|
152
|
-
if (content instanceof this.namespace.elements.Element) {
|
|
153
|
-
return this.serialise(content);
|
|
154
|
-
}
|
|
155
|
-
if (content instanceof this.namespace.KeyValuePair) {
|
|
156
|
-
const kvp = content;
|
|
157
|
-
const pair = {
|
|
158
|
-
key: this.serialise(kvp.key)
|
|
159
|
-
};
|
|
160
|
-
if (kvp.value) {
|
|
161
|
-
pair.value = this.serialise(kvp.value);
|
|
162
|
-
}
|
|
163
|
-
return pair;
|
|
164
|
-
}
|
|
165
|
-
if (content && Array.isArray(content)) {
|
|
166
|
-
if (content.length === 0) {
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
return content.map(item => this.serialise(item));
|
|
170
|
-
}
|
|
171
|
-
return content;
|
|
172
|
-
}
|
|
173
|
-
deserialiseContent(content) {
|
|
174
|
-
if (content) {
|
|
175
|
-
if (content.element) {
|
|
176
|
-
return this.deserialise(content);
|
|
177
|
-
}
|
|
178
|
-
if (content.key) {
|
|
179
|
-
const pair = new this.namespace.KeyValuePair(this.deserialise(content.key));
|
|
180
|
-
if (content.value) {
|
|
181
|
-
pair.value = this.deserialise(content.value);
|
|
182
|
-
}
|
|
183
|
-
return pair;
|
|
184
|
-
}
|
|
185
|
-
if (Array.isArray(content)) {
|
|
186
|
-
return content.map(item => this.deserialise(item));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return content;
|
|
190
|
-
}
|
|
191
|
-
serialiseMeta(element) {
|
|
192
|
-
const meta = {};
|
|
193
|
-
const rawKeys = [];
|
|
194
|
-
let hasEntries = false;
|
|
195
|
-
for (const [key, value] of Object.entries(element.meta)) {
|
|
196
|
-
if (value instanceof this.namespace.elements.Element) {
|
|
197
|
-
meta[key] = this.serialise(value);
|
|
198
|
-
hasEntries = true;
|
|
199
|
-
} else if (value !== undefined) {
|
|
200
|
-
// refract primitives to maintain JSON Refract spec compatibility
|
|
201
|
-
const refracted = element.refract(value);
|
|
202
|
-
meta[key] = this.serialise(refracted);
|
|
203
|
-
rawKeys.push(key);
|
|
204
|
-
hasEntries = true;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return hasEntries ? {
|
|
208
|
-
meta,
|
|
209
|
-
rawKeys
|
|
210
|
-
} : undefined;
|
|
211
|
-
}
|
|
212
|
-
serialiseObject(obj) {
|
|
213
|
-
const result = {};
|
|
214
|
-
obj.forEach((value, key) => {
|
|
215
|
-
if (value) {
|
|
216
|
-
result[key.toValue()] = this.serialise(value);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
if (Object.keys(result).length === 0) {
|
|
220
|
-
return undefined;
|
|
221
|
-
}
|
|
222
|
-
return result;
|
|
223
|
-
}
|
|
224
|
-
deserialiseObject(from, to) {
|
|
225
|
-
Object.keys(from).forEach(key => {
|
|
226
|
-
to.set(key, this.deserialise(from[key]));
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
var _default = exports.default = JSONSerialiser;
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import SourceMapElement from "../elements/SourceMap.mjs";
|
|
2
|
-
import StyleElement from "../elements/Style.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Serialized representation of an Element in JSON Refract format.
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Serialized representation of a KeyValuePair in JSON Refract format.
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Possible content types in a serialized element.
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Input document format for deserialization.
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* JSONSerialiser handles serialization and deserialization of ApiDOM elements
|
|
21
|
-
* to and from JSON Refract format.
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
class JSONSerialiser {
|
|
25
|
-
namespace;
|
|
26
|
-
|
|
27
|
-
// This will be set via prototype assignment to avoid circular dependency
|
|
28
|
-
|
|
29
|
-
constructor(namespace) {
|
|
30
|
-
this.namespace = namespace || new this.Namespace();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Serializes an Element to JSON Refract format.
|
|
35
|
-
*/
|
|
36
|
-
serialise(element) {
|
|
37
|
-
if (!(element instanceof this.namespace.elements.Element)) {
|
|
38
|
-
throw new TypeError(`Given element \`${element}\` is not an Element instance`);
|
|
39
|
-
}
|
|
40
|
-
const payload = {
|
|
41
|
-
element: element.element
|
|
42
|
-
};
|
|
43
|
-
if (!element.isMetaEmpty) {
|
|
44
|
-
const serialisedMeta = this.serialiseMeta(element);
|
|
45
|
-
if (serialisedMeta) {
|
|
46
|
-
payload.meta = serialisedMeta.meta;
|
|
47
|
-
if (serialisedMeta.rawKeys.length > 0) {
|
|
48
|
-
payload.__meta_raw__ = serialisedMeta.rawKeys;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (!element.isAttributesEmpty) {
|
|
53
|
-
payload.attributes = this.serialiseObject(element.attributes);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Serialize source position as __mappings__ in meta (skip for SourceMapElement itself)
|
|
57
|
-
if (!(element instanceof SourceMapElement)) {
|
|
58
|
-
const sourceMap = SourceMapElement.from(element);
|
|
59
|
-
if (sourceMap) {
|
|
60
|
-
if (!payload.meta) {
|
|
61
|
-
payload.meta = {};
|
|
62
|
-
}
|
|
63
|
-
payload.meta.__mappings__ = this.serialise(sourceMap);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Serialize style as __styles__ in meta (skip for StyleElement itself)
|
|
68
|
-
if (!(element instanceof StyleElement)) {
|
|
69
|
-
const styleElement = StyleElement.from(element);
|
|
70
|
-
if (styleElement) {
|
|
71
|
-
if (!payload.meta) {
|
|
72
|
-
payload.meta = {};
|
|
73
|
-
}
|
|
74
|
-
payload.meta.__styles__ = this.serialise(styleElement);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const content = this.serialiseContent(element.content);
|
|
78
|
-
if (content !== undefined) {
|
|
79
|
-
payload.content = content;
|
|
80
|
-
}
|
|
81
|
-
return payload;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Deserializes a JSON Refract document to an Element.
|
|
86
|
-
*/
|
|
87
|
-
deserialise(value) {
|
|
88
|
-
if (!value.element) {
|
|
89
|
-
throw new Error('Given value is not an object containing an element name');
|
|
90
|
-
}
|
|
91
|
-
const ElementClass = this.namespace.getElementClass(value.element);
|
|
92
|
-
const element = new ElementClass();
|
|
93
|
-
if (element.element !== value.element) {
|
|
94
|
-
element.element = value.element;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Extract special meta keys without mutating input, filter remaining meta
|
|
98
|
-
let mappingsDoc;
|
|
99
|
-
let stylesDoc;
|
|
100
|
-
let metaToDeserialize = value.meta;
|
|
101
|
-
if (value.meta?.__mappings__ || value.meta?.__styles__) {
|
|
102
|
-
const {
|
|
103
|
-
__mappings__,
|
|
104
|
-
__styles__,
|
|
105
|
-
...rest
|
|
106
|
-
} = value.meta;
|
|
107
|
-
mappingsDoc = __mappings__;
|
|
108
|
-
stylesDoc = __styles__;
|
|
109
|
-
metaToDeserialize = Object.keys(rest).length > 0 ? rest : undefined;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// determine which meta keys were raw primitives before serialization
|
|
113
|
-
const rawKeys = value.__meta_raw__ ? new Set(value.__meta_raw__) : undefined;
|
|
114
|
-
if (metaToDeserialize) {
|
|
115
|
-
for (const [key, doc] of Object.entries(metaToDeserialize)) {
|
|
116
|
-
const deserialized = this.deserialise(doc);
|
|
117
|
-
// unwrap keys that were raw primitives before serialization
|
|
118
|
-
element.setMetaProperty(key, rawKeys?.has(key) ? deserialized.toValue() : deserialized);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Restore source position from __mappings__
|
|
123
|
-
if (mappingsDoc) {
|
|
124
|
-
const sourceMap = this.deserialise(mappingsDoc);
|
|
125
|
-
sourceMap.applyTo(element);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Restore style from __styles__
|
|
129
|
-
if (stylesDoc) {
|
|
130
|
-
const styleElement = this.deserialise(stylesDoc);
|
|
131
|
-
styleElement.applyTo(element);
|
|
132
|
-
}
|
|
133
|
-
if (value.attributes) {
|
|
134
|
-
this.deserialiseObject(value.attributes, element.attributes);
|
|
135
|
-
}
|
|
136
|
-
const content = this.deserialiseContent(value.content);
|
|
137
|
-
if (content !== undefined || element.content === null) {
|
|
138
|
-
element.content = content;
|
|
139
|
-
}
|
|
140
|
-
return element;
|
|
141
|
-
}
|
|
142
|
-
serialiseContent(content) {
|
|
143
|
-
if (content instanceof this.namespace.elements.Element) {
|
|
144
|
-
return this.serialise(content);
|
|
145
|
-
}
|
|
146
|
-
if (content instanceof this.namespace.KeyValuePair) {
|
|
147
|
-
const kvp = content;
|
|
148
|
-
const pair = {
|
|
149
|
-
key: this.serialise(kvp.key)
|
|
150
|
-
};
|
|
151
|
-
if (kvp.value) {
|
|
152
|
-
pair.value = this.serialise(kvp.value);
|
|
153
|
-
}
|
|
154
|
-
return pair;
|
|
155
|
-
}
|
|
156
|
-
if (content && Array.isArray(content)) {
|
|
157
|
-
if (content.length === 0) {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
return content.map(item => this.serialise(item));
|
|
161
|
-
}
|
|
162
|
-
return content;
|
|
163
|
-
}
|
|
164
|
-
deserialiseContent(content) {
|
|
165
|
-
if (content) {
|
|
166
|
-
if (content.element) {
|
|
167
|
-
return this.deserialise(content);
|
|
168
|
-
}
|
|
169
|
-
if (content.key) {
|
|
170
|
-
const pair = new this.namespace.KeyValuePair(this.deserialise(content.key));
|
|
171
|
-
if (content.value) {
|
|
172
|
-
pair.value = this.deserialise(content.value);
|
|
173
|
-
}
|
|
174
|
-
return pair;
|
|
175
|
-
}
|
|
176
|
-
if (Array.isArray(content)) {
|
|
177
|
-
return content.map(item => this.deserialise(item));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return content;
|
|
181
|
-
}
|
|
182
|
-
serialiseMeta(element) {
|
|
183
|
-
const meta = {};
|
|
184
|
-
const rawKeys = [];
|
|
185
|
-
let hasEntries = false;
|
|
186
|
-
for (const [key, value] of Object.entries(element.meta)) {
|
|
187
|
-
if (value instanceof this.namespace.elements.Element) {
|
|
188
|
-
meta[key] = this.serialise(value);
|
|
189
|
-
hasEntries = true;
|
|
190
|
-
} else if (value !== undefined) {
|
|
191
|
-
// refract primitives to maintain JSON Refract spec compatibility
|
|
192
|
-
const refracted = element.refract(value);
|
|
193
|
-
meta[key] = this.serialise(refracted);
|
|
194
|
-
rawKeys.push(key);
|
|
195
|
-
hasEntries = true;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return hasEntries ? {
|
|
199
|
-
meta,
|
|
200
|
-
rawKeys
|
|
201
|
-
} : undefined;
|
|
202
|
-
}
|
|
203
|
-
serialiseObject(obj) {
|
|
204
|
-
const result = {};
|
|
205
|
-
obj.forEach((value, key) => {
|
|
206
|
-
if (value) {
|
|
207
|
-
result[key.toValue()] = this.serialise(value);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
if (Object.keys(result).length === 0) {
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
|
-
deserialiseObject(from, to) {
|
|
216
|
-
Object.keys(from).forEach(key => {
|
|
217
|
-
to.set(key, this.deserialise(from[key]));
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
export default JSONSerialiser;
|
package/src/types.cjs
DELETED
package/src/types.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|