@adep/runtime 0.2.5 → 0.2.6

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 (2) hide show
  1. package/dist/index.js +11 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1292,7 +1292,7 @@ var rotr = (x, n) => x >>> n | x << 32 - n;
1292
1292
  function compress(h, block, w) {
1293
1293
  for (let i = 0; i < 16; i += 1) {
1294
1294
  const j = i * 4;
1295
- w[i] = (block[j] ?? 0) << 24 | (block[j + 1] ?? 0) << 16 | (block[j + 2] ?? 0) << 8 | (block[j + 3] ?? 0);
1295
+ w[i] = block[j] << 24 | block[j + 1] << 16 | block[j + 2] << 8 | block[j + 3];
1296
1296
  }
1297
1297
  for (let i = 16; i < 64; i += 1) {
1298
1298
  const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
@@ -2014,6 +2014,10 @@ function toNumber(raw) {
2014
2014
  const n = Number(t);
2015
2015
  return Number.isNaN(n) ? null : n;
2016
2016
  }
2017
+ function arithmeticOperand(v) {
2018
+ const n = Number(v);
2019
+ return Number.isFinite(n) ? n : 0;
2020
+ }
2017
2021
  function stripQuotes(raw) {
2018
2022
  const t = raw.trim();
2019
2023
  if (/^'.*'$/.test(t)) return t.slice(1, -1);
@@ -2183,10 +2187,6 @@ function resolveSetValue(value, existing, row) {
2183
2187
  return value;
2184
2188
  }
2185
2189
  function evalArithmetic(src, existing, row) {
2186
- const num = (v) => {
2187
- const n2 = Number(v);
2188
- return Number.isFinite(n2) ? n2 : 0;
2189
- };
2190
2190
  let i = 0;
2191
2191
  const n = src.length;
2192
2192
  const skip = () => {
@@ -2231,7 +2231,7 @@ function evalArithmetic(src, existing, row) {
2231
2231
  const id = parseIdent();
2232
2232
  if (id !== null) {
2233
2233
  const v = id.excluded ? row[id.col] : existing[id.col];
2234
- return num(v);
2234
+ return arithmeticOperand(v);
2235
2235
  }
2236
2236
  return 0;
2237
2237
  };
@@ -2661,6 +2661,9 @@ function parseSelectItem(raw) {
2661
2661
  const plain = unqualifyColumn(ident(name));
2662
2662
  return { name: plain, qualified, alias: as === null ? plain : ident(as[1] ?? ""), star: false };
2663
2663
  }
2664
+ function projectValueOf(row, item) {
2665
+ return item.qualified !== "" && row[item.qualified] !== void 0 ? row[item.qualified] : row[item.name];
2666
+ }
2664
2667
  function project(rows, selectRaw) {
2665
2668
  if (/^count\s*\(\s*\*/i.test(selectRaw) || /^count\s*\(\s*1\)/i.test(selectRaw)) {
2666
2669
  const alias = selectRaw.match(/\bAS\s+([A-Za-z_][A-Za-z0-9_]*)/i)?.[1] ?? "n";
@@ -2672,20 +2675,19 @@ function project(rows, selectRaw) {
2672
2675
  }
2673
2676
  if (selectRaw.trim() === "*") return rows;
2674
2677
  const items = selectRaw.split(",").map(parseSelectItem);
2675
- const valueOf = (row, item) => item.qualified !== "" && row[item.qualified] !== void 0 ? row[item.qualified] : row[item.name];
2676
2678
  if (items.some((item) => item.star)) {
2677
2679
  return rows.map((row) => {
2678
2680
  const out = { ...row };
2679
2681
  for (const item of items) {
2680
2682
  if (item.star) continue;
2681
- out[item.alias] = valueOf(row, item);
2683
+ out[item.alias] = projectValueOf(row, item);
2682
2684
  }
2683
2685
  return out;
2684
2686
  });
2685
2687
  }
2686
2688
  return rows.map((row) => {
2687
2689
  const out = {};
2688
- for (const item of items) out[item.alias] = valueOf(row, item);
2690
+ for (const item of items) out[item.alias] = projectValueOf(row, item);
2689
2691
  return out;
2690
2692
  });
2691
2693
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adep/runtime",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,