jsql-neo 3.5.0 → 3.5.1

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.
@@ -5,10 +5,11 @@ function safeJsonParse(str) {
5
5
  try { return JSON.parse(str); } catch { return str; }
6
6
  }
7
7
 
8
- const INT_TAG = 1;
8
+ const INT64_TAG = 1;
9
9
  const FLOAT_TAG = 2;
10
10
  const STR_TAG = 3;
11
11
  const BOOL_TAG = 4;
12
+ const INT32_TAG = 5;
12
13
 
13
14
  function encodeBatch(rows) {
14
15
  if (rows.length === 0) return new Uint8Array(0);
@@ -36,7 +37,7 @@ function encodeBatch(rows) {
36
37
  const v = row[fieldNames[0]];
37
38
  if (v === null || v === undefined) { off = buf.writeUInt8(0, off); }
38
39
  else if (typeof v === 'number') {
39
- if (Number.isInteger(v)) { off = buf.writeUInt8(INT_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); }
40
+ if (Number.isInteger(v)) { if (v >= -2147483648 && v <= 2147483647) { off = buf.writeUInt8(INT32_TAG, off); off = buf.writeInt32LE(v, off); } else { off = buf.writeUInt8(INT64_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); } }
40
41
  else { off = buf.writeUInt8(FLOAT_TAG, off); off = buf.writeDoubleLE(v, off); }
41
42
  } else if (typeof v === 'string') {
42
43
  off = buf.writeUInt8(STR_TAG, off);
@@ -49,7 +50,7 @@ function encodeBatch(rows) {
49
50
  const v = row[fieldNames[1]];
50
51
  if (v === null || v === undefined) { off = buf.writeUInt8(0, off); }
51
52
  else if (typeof v === 'number') {
52
- if (Number.isInteger(v)) { off = buf.writeUInt8(INT_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); }
53
+ if (Number.isInteger(v)) { if (v >= -2147483648 && v <= 2147483647) { off = buf.writeUInt8(INT32_TAG, off); off = buf.writeInt32LE(v, off); } else { off = buf.writeUInt8(INT64_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); } }
53
54
  else { off = buf.writeUInt8(FLOAT_TAG, off); off = buf.writeDoubleLE(v, off); }
54
55
  } else if (typeof v === 'string') {
55
56
  off = buf.writeUInt8(STR_TAG, off);
@@ -62,7 +63,7 @@ function encodeBatch(rows) {
62
63
  const v = row[fieldNames[2]];
63
64
  if (v === null || v === undefined) { off = buf.writeUInt8(0, off); }
64
65
  else if (typeof v === 'number') {
65
- if (Number.isInteger(v)) { off = buf.writeUInt8(INT_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); }
66
+ if (Number.isInteger(v)) { if (v >= -2147483648 && v <= 2147483647) { off = buf.writeUInt8(INT32_TAG, off); off = buf.writeInt32LE(v, off); } else { off = buf.writeUInt8(INT64_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); } }
66
67
  else { off = buf.writeUInt8(FLOAT_TAG, off); off = buf.writeDoubleLE(v, off); }
67
68
  } else if (typeof v === 'string') {
68
69
  off = buf.writeUInt8(STR_TAG, off);
@@ -75,7 +76,7 @@ function encodeBatch(rows) {
75
76
  const v = row[fieldNames[3]];
76
77
  if (v === null || v === undefined) { off = buf.writeUInt8(0, off); }
77
78
  else if (typeof v === 'number') {
78
- if (Number.isInteger(v)) { off = buf.writeUInt8(INT_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); }
79
+ if (Number.isInteger(v)) { if (v >= -2147483648 && v <= 2147483647) { off = buf.writeUInt8(INT32_TAG, off); off = buf.writeInt32LE(v, off); } else { off = buf.writeUInt8(INT64_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); } }
79
80
  else { off = buf.writeUInt8(FLOAT_TAG, off); off = buf.writeDoubleLE(v, off); }
80
81
  } else if (typeof v === 'string') {
81
82
  off = buf.writeUInt8(STR_TAG, off);
@@ -88,7 +89,7 @@ function encodeBatch(rows) {
88
89
  const v = row[fieldNames[4]];
89
90
  if (v === null || v === undefined) { off = buf.writeUInt8(0, off); }
90
91
  else if (typeof v === 'number') {
91
- if (Number.isInteger(v)) { off = buf.writeUInt8(INT_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); }
92
+ if (Number.isInteger(v)) { if (v >= -2147483648 && v <= 2147483647) { off = buf.writeUInt8(INT32_TAG, off); off = buf.writeInt32LE(v, off); } else { off = buf.writeUInt8(INT64_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); } }
92
93
  else { off = buf.writeUInt8(FLOAT_TAG, off); off = buf.writeDoubleLE(v, off); }
93
94
  } else if (typeof v === 'string') {
94
95
  off = buf.writeUInt8(STR_TAG, off);
@@ -102,7 +103,7 @@ function encodeBatch(rows) {
102
103
  const v = row[fieldNames[fi]];
103
104
  if (v === null || v === undefined) { off = buf.writeUInt8(0, off); }
104
105
  else if (typeof v === 'number') {
105
- if (Number.isInteger(v)) { off = buf.writeUInt8(INT_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); }
106
+ if (Number.isInteger(v)) { if (v >= -2147483648 && v <= 2147483647) { off = buf.writeUInt8(INT32_TAG, off); off = buf.writeInt32LE(v, off); } else { off = buf.writeUInt8(INT64_TAG, off); off = buf.writeBigInt64LE(BigInt(v), off); } }
106
107
  else { off = buf.writeUInt8(FLOAT_TAG, off); off = buf.writeDoubleLE(v, off); }
107
108
  } else if (typeof v === 'string') {
108
109
  off = buf.writeUInt8(STR_TAG, off);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsql-neo",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "JSQL-NEO — Rust-powered embedded database with WASM, REST API, B-Tree indexes, WAL, crash recovery",
5
5
  "main": "index.js",
6
6
  "files": [
Binary file