@muze-nl/od-jsontag 0.4.5 → 0.4.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 +1 -1
- package/src/parse.mjs +17 -2
- package/src/symbols.mjs +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muze-nl/od-jsontag",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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>",
|
package/src/parse.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import JSONTag from '@muze-nl/jsontag';
|
|
2
2
|
import Null from '@muze-nl/jsontag/src/lib/Null.mjs'
|
|
3
3
|
import serialize from './serialize.mjs'
|
|
4
|
-
import {source,isProxy,proxyType,getBuffer,getIndex,isChanged,isParsed,position,parent,resultSet} from './symbols.mjs'
|
|
4
|
+
import {source,isProxy,proxyType,getBuffer,getIndex,isChanged,isParsed,position,parent,resultSet, previous} from './symbols.mjs'
|
|
5
5
|
|
|
6
6
|
const encoder = new TextEncoder()
|
|
7
7
|
const decoder = new TextDecoder()
|
|
@@ -233,7 +233,10 @@ export default class Parser extends JSONTag.Parser
|
|
|
233
233
|
}
|
|
234
234
|
if (target[prop] === value) {
|
|
235
235
|
return true
|
|
236
|
-
}
|
|
236
|
+
}
|
|
237
|
+
if (!target[previous]) {
|
|
238
|
+
target[previous] = JSONTag.clone(target)
|
|
239
|
+
}
|
|
237
240
|
target[prop] = value
|
|
238
241
|
target[isChanged] = true
|
|
239
242
|
target[parent][isChanged] = true
|
|
@@ -252,6 +255,9 @@ export default class Parser extends JSONTag.Parser
|
|
|
252
255
|
if (typeof target[prop] === 'undefined') {
|
|
253
256
|
return true
|
|
254
257
|
}
|
|
258
|
+
if (!target[previous]) {
|
|
259
|
+
target[previous] = JSONTag.clone(target)
|
|
260
|
+
}
|
|
255
261
|
delete target[prop]
|
|
256
262
|
target[isChanged] = true
|
|
257
263
|
target[parent][isChanged] = true
|
|
@@ -338,6 +344,9 @@ export default class Parser extends JSONTag.Parser
|
|
|
338
344
|
if (target[prop] === value) {
|
|
339
345
|
return true
|
|
340
346
|
}
|
|
347
|
+
if (!target[previous]) {
|
|
348
|
+
target[previous] = JSONTag.clone(target)
|
|
349
|
+
}
|
|
341
350
|
target[prop] = value
|
|
342
351
|
target[isChanged] = true
|
|
343
352
|
return true
|
|
@@ -353,6 +362,9 @@ export default class Parser extends JSONTag.Parser
|
|
|
353
362
|
if (typeof target[prop] === 'undefined') {
|
|
354
363
|
return true
|
|
355
364
|
}
|
|
365
|
+
if (!target[previous]) {
|
|
366
|
+
target[previous] = JSONTag.clone(target)
|
|
367
|
+
}
|
|
356
368
|
delete target[prop]
|
|
357
369
|
target[isChanged] = true
|
|
358
370
|
return true
|
|
@@ -373,6 +385,9 @@ export default class Parser extends JSONTag.Parser
|
|
|
373
385
|
return undefined
|
|
374
386
|
}
|
|
375
387
|
this.firstParse(target)
|
|
388
|
+
if (!target[previous]) {
|
|
389
|
+
target[previous] = JSONTag.clone(target)
|
|
390
|
+
}
|
|
376
391
|
target[isChanged] = true
|
|
377
392
|
return Object.defineProperty(target, prop, descriptor)
|
|
378
393
|
},
|
package/src/symbols.mjs
CHANGED
|
@@ -8,4 +8,5 @@ export const isParsed = Symbol('isParsed')
|
|
|
8
8
|
export const getString = Symbol('getString')
|
|
9
9
|
export const position = Symbol('position')
|
|
10
10
|
export const parent = Symbol('parent')
|
|
11
|
-
export const resultSet = Symbol('resultSet')
|
|
11
|
+
export const resultSet = Symbol('resultSet')
|
|
12
|
+
export const previous = Symbol('previous')
|