@muze-nl/od-jsontag 0.2.4 → 0.2.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/package.json +2 -2
- package/src/serialize.mjs +5 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muze-nl/od-jsontag",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "On Demand JSONTag: parse/serialize large datastructures on demand, useful for sharing data between threads",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Auke van Slooten <auke@muze.nl>",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/muze-nl/od-jsontag.git"
|
|
22
|
+
"url": "git+https://github.com/muze-nl/od-jsontag.git"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=20.0.0"
|
package/src/serialize.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export default function serialize(value, options={}) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function stringifyValue(value, inarray=false) {
|
|
31
|
+
function stringifyValue(value, inarray=false, current) {
|
|
32
32
|
let prop
|
|
33
33
|
let typeString = odJSONTag.getTypeString(value)
|
|
34
34
|
let type = odJSONTag.getType(value)
|
|
@@ -80,7 +80,7 @@ export default function serialize(value, options={}) {
|
|
|
80
80
|
prop = typeString + value
|
|
81
81
|
break
|
|
82
82
|
case 'array':
|
|
83
|
-
let entries = value.map(e => stringifyValue(e, true)).join(',')
|
|
83
|
+
let entries = value.map(e => stringifyValue(e, true, current)).join(',')
|
|
84
84
|
prop = typeString + '[' + entries + ']'
|
|
85
85
|
break
|
|
86
86
|
case 'object':
|
|
@@ -127,7 +127,7 @@ export default function serialize(value, options={}) {
|
|
|
127
127
|
let props = []
|
|
128
128
|
for (let key of Object.getOwnPropertyNames(object)) {
|
|
129
129
|
let value = object[key]
|
|
130
|
-
let prop = stringifyValue(value)
|
|
130
|
+
let prop = stringifyValue(value, false, current)
|
|
131
131
|
let enumerable = object.propertyIsEnumerable(key) ? '' : '#'
|
|
132
132
|
props.push(enumerable+'"'+key+'":'+prop)
|
|
133
133
|
}
|
|
@@ -157,10 +157,7 @@ export default function serialize(value, options={}) {
|
|
|
157
157
|
let currentSource = 0
|
|
158
158
|
let currentResult = 0
|
|
159
159
|
let skipCount = 0
|
|
160
|
-
let result =
|
|
161
|
-
if (options.changes) {
|
|
162
|
-
result = []
|
|
163
|
-
}
|
|
160
|
+
let result = []
|
|
164
161
|
while(currentSource<resultArray.length) {
|
|
165
162
|
if (resultArray[currentSource][isChanged] || !resultArray[currentSource][isProxy]) {
|
|
166
163
|
if (skipCount) {
|
|
@@ -177,7 +174,7 @@ export default function serialize(value, options={}) {
|
|
|
177
174
|
}
|
|
178
175
|
currentResult++
|
|
179
176
|
} else if (!options.changes) {
|
|
180
|
-
|
|
177
|
+
result[currentResult] = resultArray[currentSource][getBuffer](currentSource)
|
|
181
178
|
if (options.meta) {
|
|
182
179
|
const id=odJSONTag.getAttribute(resultArray[currentSource],'id')
|
|
183
180
|
if (id) {
|