zkjson 0.1.22 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- package/encoder.js +0 -1
- package/package.json +1 -1
- package/parse.js +10 -9
- package/uint.js +7 -2
package/encoder.js
CHANGED
package/package.json
CHANGED
package/parse.js
CHANGED
@@ -116,6 +116,7 @@ const parse = (str, size = 100, digit = 9) => {
|
|
116
116
|
var err = 0
|
117
117
|
var json = _arr(size)
|
118
118
|
var c = bn([0, size, 0, 0, 0, 0, 0, 0, 0])
|
119
|
+
var bare = 1
|
119
120
|
while (c[5] == 0) {
|
120
121
|
c = next(str, c)
|
121
122
|
var s = c[0]
|
@@ -137,7 +138,7 @@ const parse = (str, size = 100, digit = 9) => {
|
|
137
138
|
__ind = push(__ind, size, digit, _ind)
|
138
139
|
path = pushArray(path, size, digit, __ind, size)
|
139
140
|
ind = pop(ind, 5)
|
140
|
-
ind = push(ind, 5, digit, _ind +
|
141
|
+
ind = push(ind, 5, digit, _ind + 1n)
|
141
142
|
}
|
142
143
|
json = concat(
|
143
144
|
json,
|
@@ -150,9 +151,8 @@ const parse = (str, size = 100, digit = 9) => {
|
|
150
151
|
size,
|
151
152
|
digit,
|
152
153
|
)
|
153
|
-
path = popArray(path, size, digit)
|
154
|
+
if (bare == 0) path = popArray(path, size, digit)
|
154
155
|
}
|
155
|
-
|
156
156
|
val = _arr(size)
|
157
157
|
nextKey = 0
|
158
158
|
}
|
@@ -204,14 +204,13 @@ const parse = (str, size = 100, digit = 9) => {
|
|
204
204
|
if (s == 93) {
|
205
205
|
if (last(ao, 5) != 2) err = 1
|
206
206
|
ao = pop(ao, 5)
|
207
|
-
path = popArray(path, size, digit)
|
207
|
+
if (bare == 0) path = popArray(path, size, digit)
|
208
208
|
arr--
|
209
209
|
ind = pop(ind, 5)
|
210
210
|
}
|
211
211
|
if (s == 125) {
|
212
212
|
if (last(ao, 5) != 1) err = 1
|
213
213
|
ao = pop(ao, 5)
|
214
|
-
path = popArray(path, size, digit)
|
215
214
|
obj--
|
216
215
|
}
|
217
216
|
isNum = 0
|
@@ -235,7 +234,10 @@ const parse = (str, size = 100, digit = 9) => {
|
|
235
234
|
val = push(val, size, digit, s)
|
236
235
|
} else {
|
237
236
|
if (s != 32) {
|
238
|
-
if (s == 123 || s == 44)
|
237
|
+
if (s == 123 || s == 44) {
|
238
|
+
bare = 0
|
239
|
+
nextKey = 1
|
240
|
+
}
|
239
241
|
if (s == 123) {
|
240
242
|
if (last(ao, 5) == 2) {
|
241
243
|
var _ind = last(ind, 5)
|
@@ -244,7 +246,7 @@ const parse = (str, size = 100, digit = 9) => {
|
|
244
246
|
__ind = push(__ind, size, digit, _ind)
|
245
247
|
path = pushArray(path, size, digit, __ind, size)
|
246
248
|
ind = pop(ind, 5)
|
247
|
-
ind = push(ind, 5, digit, _ind +
|
249
|
+
ind = push(ind, 5, digit, _ind + 1n)
|
248
250
|
}
|
249
251
|
ao = push(ao, 5, digit, 1)
|
250
252
|
obj++
|
@@ -252,7 +254,6 @@ const parse = (str, size = 100, digit = 9) => {
|
|
252
254
|
if (s == 125) {
|
253
255
|
if (last(ao, 5) != 1) err = 1
|
254
256
|
ao = pop(ao, 5)
|
255
|
-
path = popArray(path, size, digit)
|
256
257
|
obj--
|
257
258
|
}
|
258
259
|
if (s == 91) {
|
@@ -263,7 +264,7 @@ const parse = (str, size = 100, digit = 9) => {
|
|
263
264
|
__ind = push(__ind, size, digit, _ind)
|
264
265
|
path = pushArray(path, size, digit, __ind, size)
|
265
266
|
ind = pop(ind, 5)
|
266
|
-
ind = push(ind, 5, digit, _ind +
|
267
|
+
ind = push(ind, 5, digit, _ind + 1n)
|
267
268
|
}
|
268
269
|
ind = push(ind, 5, digit, 0)
|
269
270
|
ao = push(ao, 5, digit, 2)
|
package/uint.js
CHANGED
@@ -78,7 +78,7 @@ function popArray(json, size, digit) {
|
|
78
78
|
} else {
|
79
79
|
alen = get(json, size, 0)
|
80
80
|
}
|
81
|
-
if (alen == 1) return
|
81
|
+
if (alen == 1) return arr(size)
|
82
82
|
var len = get(json, size, alen)
|
83
83
|
json = replace(json, size, digit, 0, alen - 1n)
|
84
84
|
var _sum = sum(json, size, digit, 1, alen)
|
@@ -374,6 +374,9 @@ function push(json, size, digit, c, overflow = 8) {
|
|
374
374
|
json = bn(json)
|
375
375
|
c = bn(c)
|
376
376
|
var i4 = 0n
|
377
|
+
for (var i = i4; i < size; i++) {
|
378
|
+
if (json[i] != 0) i4 = i
|
379
|
+
}
|
377
380
|
var init = 0n
|
378
381
|
while (c > 0 || init == 0) {
|
379
382
|
init = 1
|
@@ -392,7 +395,6 @@ function push(json, size, digit, c, overflow = 8) {
|
|
392
395
|
var appended = 0
|
393
396
|
for (var i = i4; i < size; i++) {
|
394
397
|
var d = digits(json[i])
|
395
|
-
if (d == 0) break
|
396
398
|
var one = 0n
|
397
399
|
var ones = 0n
|
398
400
|
var nums = 0n
|
@@ -462,6 +464,9 @@ function push(json, size, digit, c, overflow = 8) {
|
|
462
464
|
}
|
463
465
|
return json
|
464
466
|
}
|
467
|
+
function str(arr) {
|
468
|
+
return arr.map(n => n.toString())
|
469
|
+
}
|
465
470
|
function bn(arr) {
|
466
471
|
if (typeof arr == "number") return BigInt(arr)
|
467
472
|
if (!Array.isArray(arr)) return arr
|