@muze-nl/od-jsontag 0.1.5 → 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/package.json +1 -1
- package/src/parse.mjs +13 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muze-nl/od-jsontag",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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
|
@@ -25,9 +25,6 @@ export default function parse(input, meta, immutable=true)
|
|
|
25
25
|
if (!meta.baseURL) {
|
|
26
26
|
meta.baseURL = 'http://localhost/'
|
|
27
27
|
}
|
|
28
|
-
if (!meta.access) {
|
|
29
|
-
meta.access = () => true
|
|
30
|
-
}
|
|
31
28
|
let at, ch, value, result;
|
|
32
29
|
let escapee = {
|
|
33
30
|
'"': '"',
|
|
@@ -690,7 +687,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
690
687
|
} else if (prop===isChanged) {
|
|
691
688
|
return true
|
|
692
689
|
} else {
|
|
693
|
-
if (!meta.access(target, prop)) {
|
|
690
|
+
if (meta.access && !meta.access(target, prop)) {
|
|
694
691
|
return undefined
|
|
695
692
|
}
|
|
696
693
|
if (Array.isArray(target[prop])) {
|
|
@@ -700,7 +697,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
700
697
|
}
|
|
701
698
|
},
|
|
702
699
|
set(target, prop, value) {
|
|
703
|
-
if (!meta.access(target, prop)) {
|
|
700
|
+
if (meta.access && !meta.access(target, prop)) {
|
|
704
701
|
return undefined
|
|
705
702
|
}
|
|
706
703
|
if (JSONTag.getType(value)==='object' && !value[isProxy]) {
|
|
@@ -735,7 +732,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
735
732
|
return true
|
|
736
733
|
break
|
|
737
734
|
default:
|
|
738
|
-
if (!meta.access(target, prop, 'get')) {
|
|
735
|
+
if (meta.access && !meta.access(target, prop, 'get')) {
|
|
739
736
|
return undefined
|
|
740
737
|
}
|
|
741
738
|
if (Array.isArray(target[prop])) {
|
|
@@ -746,7 +743,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
746
743
|
}
|
|
747
744
|
},
|
|
748
745
|
set(target, prop, value) {
|
|
749
|
-
if (!meta.access(target, prop, 'set')) {
|
|
746
|
+
if (meta.access && !meta.access(target, prop, 'set')) {
|
|
750
747
|
return undefined
|
|
751
748
|
}
|
|
752
749
|
if (JSONTag.getType(value)==='object' && !value[isProxy]) {
|
|
@@ -778,7 +775,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
778
775
|
} else if (prop===isChanged) {
|
|
779
776
|
return target[parent][isChanged]
|
|
780
777
|
} else {
|
|
781
|
-
if (!meta.access(target, prop, 'get')) {
|
|
778
|
+
if (meta.access && !meta.access(target, prop, 'get')) {
|
|
782
779
|
return undefined
|
|
783
780
|
}
|
|
784
781
|
if (Array.isArray(target[prop])) {
|
|
@@ -792,7 +789,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
792
789
|
if (immutable) {
|
|
793
790
|
throw new Error('dataspace is immutable')
|
|
794
791
|
}
|
|
795
|
-
if (!meta.access(target, prop, 'set')) {
|
|
792
|
+
if (meta.access && !meta.access(target, prop, 'set')) {
|
|
796
793
|
return undefined
|
|
797
794
|
}
|
|
798
795
|
if (JSONTag.getType(value)==='object' && !value[isProxy]) {
|
|
@@ -806,7 +803,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
806
803
|
if (immutable) {
|
|
807
804
|
throw new Error('dataspace is immutable')
|
|
808
805
|
}
|
|
809
|
-
if (!meta.access(target, prop, 'deleteProperty')) {
|
|
806
|
+
if (meta.access && !meta.access(target, prop, 'deleteProperty')) {
|
|
810
807
|
return undefined
|
|
811
808
|
}
|
|
812
809
|
//FIXME: if target[prop] was the last reference to an object
|
|
@@ -822,7 +819,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
822
819
|
firstParse(target)
|
|
823
820
|
switch(prop) {
|
|
824
821
|
case source:
|
|
825
|
-
if (!meta.access(target, prop, 'get')) {
|
|
822
|
+
if (meta.access && !meta.access(target, prop, 'get')) {
|
|
826
823
|
return undefined
|
|
827
824
|
}
|
|
828
825
|
return target
|
|
@@ -849,7 +846,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
849
846
|
return target[isChanged]
|
|
850
847
|
break
|
|
851
848
|
default:
|
|
852
|
-
if (!meta.access(target, prop, 'get')) {
|
|
849
|
+
if (meta.access && !meta.access(target, prop, 'get')) {
|
|
853
850
|
return undefined
|
|
854
851
|
}
|
|
855
852
|
if (Array.isArray(target[prop])) {
|
|
@@ -866,7 +863,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
866
863
|
}
|
|
867
864
|
firstParse(target)
|
|
868
865
|
if (prop!==isChanged) {
|
|
869
|
-
if (prop!=resultSet && !meta.access(target, prop, 'set')) {
|
|
866
|
+
if (prop!=resultSet && meta.access && !meta.access(target, prop, 'set')) {
|
|
870
867
|
return undefined
|
|
871
868
|
}
|
|
872
869
|
if (JSONTag.getType(value)==='object' && !value[isProxy]) {
|
|
@@ -881,7 +878,7 @@ export default function parse(input, meta, immutable=true)
|
|
|
881
878
|
if (immutable) {
|
|
882
879
|
throw new Error('dataspace is immutable')
|
|
883
880
|
}
|
|
884
|
-
if (!meta.access(target, prop, 'deleteProperty')) {
|
|
881
|
+
if (meta.access && !meta.access(target, prop, 'deleteProperty')) {
|
|
885
882
|
return undefined
|
|
886
883
|
}
|
|
887
884
|
firstParse(target)
|
|
@@ -901,14 +898,14 @@ export default function parse(input, meta, immutable=true)
|
|
|
901
898
|
if (immutable) {
|
|
902
899
|
throw new Error('dataspace is immutable')
|
|
903
900
|
}
|
|
904
|
-
if (!meta.access(target, prop, 'defineProperty')) {
|
|
901
|
+
if (meta.access && !meta.access(target, prop, 'defineProperty')) {
|
|
905
902
|
return undefined
|
|
906
903
|
}
|
|
907
904
|
firstParse(target)
|
|
908
905
|
Object.defineProperty(target, prop, descriptor)
|
|
909
906
|
},
|
|
910
907
|
has(target, prop) {
|
|
911
|
-
if (!meta.access(target, prop, 'has')) {
|
|
908
|
+
if (meta.access && !meta.access(target, prop, 'has')) {
|
|
912
909
|
return false
|
|
913
910
|
}
|
|
914
911
|
firstParse()
|