nv-buf-serde 0.0.7 → 0.0.9
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/TEST/hole-tst.js +3 -1
- package/TEST/tst2.json +1 -0
- package/misc.js +1 -1
- package/package.json +2 -2
- package/r.js +10 -5
- package/w.js +4 -4
package/TEST/hole-tst.js
CHANGED
package/TEST/tst2.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[0,1,2,3]
|
package/misc.js
CHANGED
|
@@ -65,7 +65,7 @@ const GetArrayForInLength = (arr) => {
|
|
|
65
65
|
|
|
66
66
|
const IsArrayHasHole = (arr)=> GetArrayForEachLength(arr)!== arr.length;
|
|
67
67
|
|
|
68
|
-
const IsSmi = (n) =>
|
|
68
|
+
const IsSmi = (n) => Number.isInteger(n) && (!Object.is(n,-0)) && _zigzag.is_smi(n);
|
|
69
69
|
|
|
70
70
|
const GetArrayPackedInfo = (arr)=> {
|
|
71
71
|
let is_packed_smi = _t;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"nv-buf-bi": "^1.0.5",
|
|
4
|
-
"nv-buf-jstr": "^1.0.
|
|
4
|
+
"nv-buf-jstr": "^1.0.14",
|
|
5
5
|
"nv-facutil-ab": "^1.0.0",
|
|
6
6
|
"nv-facutil-istis": "^1.0.6",
|
|
7
7
|
"nv-facutil-ppgflike-is": "^1.0.1",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"nv-number-zigzag": "^1.0.1",
|
|
10
10
|
"nv-regexp-flags": "^1.0.1"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.0.
|
|
12
|
+
"version": "0.0.9",
|
|
13
13
|
"name": "nv-buf-serde",
|
|
14
14
|
"description": "nv-buf-serde ======================= - rewrite v8/src/objects/value-serializer.cc to JS - to let you use nodejs'v8.serialize AND nodejs'v8.deserialize in browser, - similiar to structuredClone AND MessageChannel-transfer, but can be used to send/recv data to server-side",
|
|
15
15
|
"main": "index.js",
|
package/r.js
CHANGED
|
@@ -367,18 +367,23 @@ const ReadHostObject = (u8a,si,ctx) => {
|
|
|
367
367
|
let typeIndex = a3[0];
|
|
368
368
|
let ctor = ArrayBufferViewIndexToCtor[typeIndex];
|
|
369
369
|
let BYTES_PER_ELEMENT = ctor.BYTES_PER_ELEMENT ;
|
|
370
|
+
|
|
370
371
|
si = a3[2];
|
|
371
372
|
a3 = ReadUint32(u8a,si,ctx);
|
|
372
|
-
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
let byteLength = a3[0];
|
|
373
376
|
si = a3[2];
|
|
374
377
|
let offset = si;
|
|
375
378
|
a3 = ReadRawBytes(u8a,si,byteLength,ctx);
|
|
376
|
-
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
let buf;
|
|
377
382
|
if(si%BYTES_PER_ELEMENT === 0) {
|
|
378
|
-
|
|
383
|
+
buf = new ctor(a3[0].buffer,si,byteLength);
|
|
379
384
|
} else {
|
|
380
|
-
|
|
381
|
-
|
|
385
|
+
//need copy
|
|
386
|
+
buf = new ctor(a3[0].buffer.slice(si,si+byteLength));
|
|
382
387
|
}
|
|
383
388
|
si = a3[2];
|
|
384
389
|
ctx.AddObjectWithID(buf);
|
package/w.js
CHANGED
|
@@ -310,12 +310,12 @@ const WriteJSMap = (a,mp,ctx) => {
|
|
|
310
310
|
|
|
311
311
|
//compatible with node delegate
|
|
312
312
|
const WriteHostObject = (a,o,ctx) => {
|
|
313
|
-
|
|
313
|
+
let abvw_sub_type = arrayBufferViewTypeToIndex(o);
|
|
314
314
|
if(abvw_sub_type>-1) {
|
|
315
315
|
WriteTag(a,SerializationTag.kHostObject,ctx);
|
|
316
316
|
WriteUint32(a, abvw_sub_type, ctx);
|
|
317
317
|
WriteUint32(a, o.byteLength, ctx);
|
|
318
|
-
let u8a = new Uint8Array(o.buffer);
|
|
318
|
+
let u8a = new Uint8Array(o.buffer,o.byteOffset,o.byteLength);
|
|
319
319
|
WriteRawBytes(a,u8a,ctx);
|
|
320
320
|
return(a);
|
|
321
321
|
} else {
|
|
@@ -404,7 +404,7 @@ const WriteJSArray = (a,o,ctx) => {
|
|
|
404
404
|
const WriteJSReceiver = (a,o,ctx) => {
|
|
405
405
|
if(is_untf(o)) {
|
|
406
406
|
WriteOddball(a,o,ctx);
|
|
407
|
-
} else if(_misc.IsSmi(o)) {
|
|
407
|
+
} else if(_misc.IsSmi(o)) {
|
|
408
408
|
WriteSmi(a,o,ctx);
|
|
409
409
|
} else if(_typis.is_num(o)) {
|
|
410
410
|
WriteHeapNumber(a,o,ctx);
|
|
@@ -415,7 +415,7 @@ const WriteJSReceiver = (a,o,ctx) => {
|
|
|
415
415
|
} else if(_typis.is_sym(o)) {
|
|
416
416
|
let phantom = CreatFakeCantBeSered("Symbol",o.description);
|
|
417
417
|
WriteJSObject(a,phantom,ctx);
|
|
418
|
-
|
|
418
|
+
} else {
|
|
419
419
|
let [already_exists,idx] = ctx.idmap.FindOrInsert(o);
|
|
420
420
|
if (already_exists) {
|
|
421
421
|
WriteTag(a,SerializationTag.kObjectReference,ctx);
|