jsql-neo 6.5.8 → 6.5.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **One engine to rule them all** — a Rust-powered embedded database that speaks your language:
4
4
  > MySQL, PostgreSQL, MongoDB, Redis, SQL, TypeScript, **and the browser**.
5
5
 
6
- > **v6.5.8** — stable release · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
6
+ > **v6.5.9** — stable release · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
7
7
 
8
8
  ![Engines](https://img.shields.io/badge/engines-Native%20%7C%20WASM%20%7C%20Pure%20JS-7ee787)
9
9
  ![MySQL](https://img.shields.io/badge/protocol-MySQL%20compatible-1f6feb)
@@ -188,3 +188,6 @@ Apache-2.0 License — contributions welcome!
188
188
  - **GitHub:** [vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo)
189
189
  - **Issues:** [Open an issue](https://github.com/vexify-org/JSQL-neo/issues)
190
190
  - **PRs:** Fork → branch → PR — thank you!
191
+ - **Contributing:** [CONTRIBUTING.md](CONTRIBUTING.md)
192
+ - **Code of Conduct:** [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
193
+ - **Security:** [SECURITY.md](SECURITY.md) — please report vulnerabilities privately
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JSQL-NEO v6.5.8 — Rust-Powered Embedded Database (WASM + HTTP)
2
+ * JSQL-NEO v6.5.9 — Rust-Powered Embedded Database (WASM + HTTP)
3
3
  *
4
4
  * @example
5
5
  * const jsql = require('jsql-neo');
package/lib/btree.js CHANGED
@@ -173,7 +173,7 @@ class BTree {
173
173
  const s = k === undefined || k === null ? '' : String(k);
174
174
  // 不能假设键按字典序排序(数字键按数值序),必须检查所有键
175
175
  if (s.startsWith(p)) {
176
- result.push(...node.values[i]);
176
+ for (const __e of node.values[i]) result.push(__e);
177
177
  }
178
178
  }
179
179
  node = node.next;
@@ -193,7 +193,7 @@ class BTree {
193
193
  const k = node.keys[i];
194
194
  if (k > max) return result;
195
195
  if (k >= min) {
196
- result.push(...node.values[i]);
196
+ for (const __e of node.values[i]) result.push(__e);
197
197
  }
198
198
  }
199
199
  node = node.next;
@@ -209,7 +209,7 @@ class BTree {
209
209
  let node = this._findLeaf(min);
210
210
  while (node) {
211
211
  for (let i = 0; i < node.keys.length; i++) {
212
- if (node.keys[i] > min) result.push(...node.values[i]);
212
+ if (node.keys[i] > min) for (const __e of node.values[i]) result.push(__e);
213
213
  }
214
214
  node = node.next;
215
215
  }
@@ -221,7 +221,7 @@ class BTree {
221
221
  let node = this._findLeaf(min);
222
222
  while (node) {
223
223
  for (let i = 0; i < node.keys.length; i++) {
224
- if (node.keys[i] >= min) result.push(...node.values[i]);
224
+ if (node.keys[i] >= min) for (const __e of node.values[i]) result.push(__e);
225
225
  }
226
226
  node = node.next;
227
227
  }
@@ -237,7 +237,7 @@ class BTree {
237
237
  while (!node.leaf) node = node.children[0];
238
238
  while (node) {
239
239
  for (let i = 0; i < node.keys.length; i++) {
240
- if (node.keys[i] < max) result.push(...node.values[i]);
240
+ if (node.keys[i] < max) for (const __e of node.values[i]) result.push(__e);
241
241
  else return result;
242
242
  }
243
243
  node = node.next;
@@ -251,7 +251,7 @@ class BTree {
251
251
  while (!node.leaf) node = node.children[0];
252
252
  while (node) {
253
253
  for (let i = 0; i < node.keys.length; i++) {
254
- if (node.keys[i] <= max) result.push(...node.values[i]);
254
+ if (node.keys[i] <= max) for (const __e of node.values[i]) result.push(__e);
255
255
  else return result;
256
256
  }
257
257
  node = node.next;
@@ -408,9 +408,9 @@ class BTree {
408
408
  left.keys.push(midKey);
409
409
  left.values.push(midVal);
410
410
  }
411
- left.keys.push(...right.keys);
412
- left.values.push(...right.values);
413
- if (!left.leaf) left.children.push(...right.children);
411
+ for (const __e of right.keys) left.keys.push(__e);
412
+ for (const __e of right.values) left.values.push(__e);
413
+ if (!left.leaf) for (const __e of right.children) left.children.push(__e);
414
414
  if (left.leaf) left.next = right.next;
415
415
 
416
416
  parent.keys.splice(index, 1);
package/lib/cache.js CHANGED
@@ -152,7 +152,7 @@ class Cache {
152
152
  throw new Error('WRONGTYPE Operation against a key holding the wrong kind of value');
153
153
  }
154
154
  if (!list) { list = []; this._getData().set(k, list); }
155
- list.push(...values.map(String));
155
+ for (const __e of values.map(String)) list.push(__e);
156
156
  this._dirty = true;
157
157
  return list.length;
158
158
  }
package/lib/database.js CHANGED
@@ -566,7 +566,7 @@ class Database {
566
566
  case 'insert': {
567
567
  const t = op.table && this._tables[op.table];
568
568
  if (!t || !Array.isArray(op.rows) || op.rows.length === 0) { failed++; break; }
569
- t._rows.push(...op.rows);
569
+ for (const __e of op.rows) t._rows.push(__e);
570
570
  touched.add(t);
571
571
  replayed++;
572
572
  break;
@@ -510,7 +510,7 @@ class JSQLFormat {
510
510
  t.schema = schema;
511
511
 
512
512
  const { rows: oldRows } = this.readTable(name);
513
- oldRows.push(...rows);
513
+ for (const __e of rows) oldRows.push(__e);
514
514
  this.writeTable(name, schema, oldRows, pkField);
515
515
  }
516
516
  }
@@ -647,10 +647,14 @@ class MongoServer {
647
647
  doc[k] = vals.reduce((a, b) => a + b, 0) / vals.length;
648
648
  } else if (v.$min !== undefined) {
649
649
  const vals = grow.map(r => r[field]).filter(v => v != null);
650
- doc[k] = vals.length ? Math.min(...vals) : null;
650
+ let best = null;
651
+ for (const x of vals) if (best === null || x < best) best = x;
652
+ doc[k] = best;
651
653
  } else if (v.$max !== undefined) {
652
654
  const vals = grow.map(r => r[field]).filter(v => v != null);
653
- doc[k] = vals.length ? Math.max(...vals) : null;
655
+ let best = null;
656
+ for (const x of vals) if (best === null || x > best) best = x;
657
+ doc[k] = best;
654
658
  } else if (v.$first !== undefined) {
655
659
  doc[k] = grow[0] ? grow[0][field] : null;
656
660
  } else if (v.$last !== undefined) {
@@ -851,7 +851,7 @@ class JSQL {
851
851
  }
852
852
  if (!(await this._runHooks('beforeUpdate', [table, pairs]))) return;
853
853
  if (!this._opBuffer.update[table]) this._opBuffer.update[table] = [];
854
- this._opBuffer.update[table].push(...pairs);
854
+ for (const __e of pairs) this._opBuffer.update[table].push(__e);
855
855
  this._scheduleOpFlush();
856
856
  }
857
857
 
@@ -170,7 +170,7 @@ function applyModifier(doc, update) {
170
170
  for (const [k, v] of Object.entries(payload)) {
171
171
  const cur = getPath(doc, k);
172
172
  const arr = Array.isArray(cur) ? cur : [];
173
- if (v && typeof v === 'object' && v.$each) arr.push(...v.$each);
173
+ if (v && typeof v === 'object' && v.$each) for (const __e of v.$each) arr.push(__e);
174
174
  else arr.push(v);
175
175
  setPath(doc, k, arr);
176
176
  }
package/lib/query.js CHANGED
@@ -706,7 +706,7 @@ class Query {
706
706
  const result = [];
707
707
  for (const group of Object.values(groups)) {
708
708
  this._applyWindowToGroup(group, fn, field, dir);
709
- result.push(...group);
709
+ for (const __e of group) result.push(__e);
710
710
  }
711
711
  return result;
712
712
  }
@@ -335,7 +335,7 @@ class RedisServer {
335
335
  if (cmd === 'LPUSH') {
336
336
  for (const val of args.slice(1)) list.unshift(val);
337
337
  } else {
338
- list.push(...args.slice(1));
338
+ for (const __e of args.slice(1)) list.push(__e);
339
339
  }
340
340
  this.db.set(args[0], { type: 'list', val: list, ttl: v ? v.ttl : null });
341
341
  this._scheduleSnapshot();
package/lib/sql.js CHANGED
@@ -4114,13 +4114,25 @@ function applyScalarFunction(fnNode, row, ctx) {
4114
4114
  }
4115
4115
  function depth(obj) {
4116
4116
  if (typeof obj !== 'object' || obj === null) return 0;
4117
- if (Array.isArray(obj)) {
4118
- if (obj.length === 0) return 1;
4119
- return 1 + Math.max(...obj.map(depth));
4117
+ let max = 0;
4118
+ const stack = [{ o: obj, d: 1 }];
4119
+ while (stack.length) {
4120
+ const { o, d } = stack.pop();
4121
+ if (typeof o !== 'object' || o === null) continue;
4122
+ if (d > max) max = d;
4123
+ if (Array.isArray(o)) {
4124
+ for (const x of o) {
4125
+ if (x && typeof x === 'object') stack.push({ o: x, d: d + 1 });
4126
+ }
4127
+ } else {
4128
+ const ks = Object.keys(o);
4129
+ for (const k of ks) {
4130
+ const x = o[k];
4131
+ if (x && typeof x === 'object') stack.push({ o: x, d: d + 1 });
4132
+ }
4133
+ }
4120
4134
  }
4121
- const keys = Object.keys(obj);
4122
- if (keys.length === 0) return 1;
4123
- return 1 + Math.max(...keys.map(k => depth(obj[k])));
4135
+ return max;
4124
4136
  }
4125
4137
  return depth(data);
4126
4138
  }
@@ -5915,7 +5927,7 @@ class SQLExecutor {
5915
5927
  _rollupRow(groupReps) {
5916
5928
  const all = [];
5917
5929
  for (const rep of groupReps) {
5918
- if (rep._group) all.push(...rep._group);
5930
+ if (rep._group) for (const __e of rep._group) all.push(__e);
5919
5931
  else all.push(rep);
5920
5932
  }
5921
5933
  const out = {};
@@ -5979,8 +5991,12 @@ class SQLExecutor {
5979
5991
  const numeric = (v) => typeof v === 'number' ||
5980
5992
  (typeof v === 'string' && String(v).trim() !== '' && Number.isFinite(Number(v)));
5981
5993
  if (vs.every(numeric)) {
5982
- const nums = vs.map(v => Number(v));
5983
- return fn === 'MIN' ? Math.min(...nums) : Math.max(...nums);
5994
+ let best = Number(vs[0]);
5995
+ for (let i = 1; i < vs.length; i++) {
5996
+ const n = Number(vs[i]);
5997
+ if (fn === 'MIN' ? n < best : n > best) best = n;
5998
+ }
5999
+ return best;
5984
6000
  }
5985
6001
  let best = vs[0];
5986
6002
  for (const v of vs.slice(1)) {
package/lib/tui.js CHANGED
@@ -72,7 +72,9 @@ function renderTable(headers, rows, maxWidth) {
72
72
  for (const w of widths) total += w + 3;
73
73
  if (total > maxCol && widths.length > 1) {
74
74
  let overshoot = total - maxCol;
75
- let i = widths.indexOf(Math.max(...widths));
75
+ let maxW = widths[0];
76
+ for (const w of widths) if (w > maxW) maxW = w;
77
+ let i = widths.indexOf(maxW);
76
78
  while (overshoot > 0) {
77
79
  if (i === -1 || widths[i] <= 3) break;
78
80
  const cut = Math.min(widths[i] - 3, overshoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsql-neo",
3
- "version": "6.5.8",
3
+ "version": "6.5.9",
4
4
  "description": "JSQL-NEO \u2014 Rust-powered embedded database with WASM, REST API, B-Tree indexes, WAL, crash recovery",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",