nv-buf-serde 0.0.8 → 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.
Files changed (4) hide show
  1. package/misc.js +1 -1
  2. package/package.json +1 -1
  3. package/r.js +10 -5
  4. package/w.js +4 -4
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) => _zigzag.is_smi(n) && Number.isInteger(n) && (!Object.is(n,-0));
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
@@ -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.8",
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
- let byteLength = a3[0];
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
- let buf;
379
+
380
+
381
+ let buf;
377
382
  if(si%BYTES_PER_ELEMENT === 0) {
378
- buf = new ctor(a3[0].buffer,si,byteLength);
383
+ buf = new ctor(a3[0].buffer,si,byteLength);
379
384
  } else {
380
- //need copy
381
- buf = new ctor(a3[0].buffer.slice(si,si+byteLength));
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
- let abvw_sub_type = arrayBufferViewTypeToIndex(o);
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
- } else {
418
+ } else {
419
419
  let [already_exists,idx] = ctx.idmap.FindOrInsert(o);
420
420
  if (already_exists) {
421
421
  WriteTag(a,SerializationTag.kObjectReference,ctx);