jlens-wasm 0.22.0 → 0.24.0

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/jlens.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /* @ts-self-types="./jlens.d.ts" */
2
- import { jlensCallable } from './snippets/jlens-wasm-ac04bd0655ab1df8/inline0.js';
3
- import { jlensBuild } from './snippets/jlens-wasm-ac04bd0655ab1df8/inline1.js';
4
- import { jlensLevel } from './snippets/jlens-wasm-ac04bd0655ab1df8/inline2.js';
5
- import { jlensNow, jlensOptions } from './snippets/jlens-wasm-ac04bd0655ab1df8/inline3.js';
6
- import * as import1 from "./snippets/jlens-wasm-ac04bd0655ab1df8/inline3.js"
2
+ import { jlensCallable } from './snippets/jlens-wasm-a9debdab99c60ae3/inline0.js';
3
+ import { jlensBuild } from './snippets/jlens-wasm-a9debdab99c60ae3/inline1.js';
4
+ import { jlensLength, jlensRead } from './snippets/jlens-wasm-a9debdab99c60ae3/inline2.js';
5
+ import { jlensNow, jlensOptions } from './snippets/jlens-wasm-a9debdab99c60ae3/inline3.js';
6
+ import * as import1 from "./snippets/jlens-wasm-a9debdab99c60ae3/inline3.js"
7
7
 
8
8
 
9
9
  /**
@@ -466,29 +466,33 @@ function __wbg_get_imports() {
466
466
  const ret = Array.isArray(arg0);
467
467
  return ret;
468
468
  },
469
- __wbg_jlensBuild_6c80a1277f9d75a4: function(arg0, arg1, arg2, arg3, arg4, arg5) {
469
+ __wbg_jlensBuild_c080c54ff696f1bc: function(arg0, arg1, arg2, arg3, arg4, arg5) {
470
470
  const ret = jlensBuild(getArrayU32FromWasm0(arg0, arg1), getArrayF64FromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
471
471
  return ret;
472
472
  },
473
- __wbg_jlensCallable_a3761791bd2a6617: function(arg0, arg1) {
473
+ __wbg_jlensCallable_d71b3d3cab81291b: function(arg0, arg1) {
474
474
  const ret = jlensCallable(arg0, arg1 >>> 0);
475
475
  return ret;
476
476
  },
477
- __wbg_jlensLevel_bc1d32355a62b324: function() { return handleError(function (arg0, arg1, arg2) {
478
- const ret = jlensLevel(arg0, arg1 >>> 0, arg2 >>> 0);
477
+ __wbg_jlensLength_37078091ff1c5430: function() { return handleError(function (arg0, arg1) {
478
+ const ret = jlensLength(arg0, arg1 >>> 0);
479
479
  return ret;
480
480
  }, arguments); },
481
- __wbg_jlensNow_f563849f46ab599b: function(arg0) {
481
+ __wbg_jlensNow_b49cf705b4ee1b30: function(arg0) {
482
482
  const ret = jlensNow();
483
483
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
484
484
  const len1 = WASM_VECTOR_LEN;
485
485
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
486
486
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
487
487
  },
488
- __wbg_jlensOptions_6e4f3a120f026a2b: function() { return handleError(function (arg0) {
488
+ __wbg_jlensOptions_5fb91fee9761be08: function() { return handleError(function (arg0) {
489
489
  const ret = jlensOptions(arg0);
490
490
  return ret;
491
491
  }, arguments); },
492
+ __wbg_jlensRead_28c2da22544ebb1d: function() { return handleError(function (arg0, arg1, arg2, arg3) {
493
+ const ret = jlensRead(arg0, arg1 >>> 0, arg2 >>> 0, arg3 >>> 0);
494
+ return ret;
495
+ }, arguments); },
492
496
  __wbg_length_3121141f8e1c8c58: function(arg0) {
493
497
  const ret = arg0.length;
494
498
  return ret;
@@ -601,7 +605,7 @@ function __wbg_get_imports() {
601
605
  return {
602
606
  __proto__: null,
603
607
  "./jlens_bg.js": import0,
604
- "./snippets/jlens-wasm-ac04bd0655ab1df8/inline3.js": import1,
608
+ "./snippets/jlens-wasm-a9debdab99c60ae3/inline3.js": import1,
605
609
  };
606
610
  }
607
611
 
package/jlens_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jlens-wasm",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "JSONata in WebAssembly, with evaluation audits and schema-driven autocomplete",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -2,18 +2,20 @@
2
2
  const CIRCULAR = "Converting circular structure to JSON";
3
3
  const BIGINT = "Do not know how to serialize a BigInt";
4
4
 
5
- // Reads one level: `kind` 0 is the input itself (`node` is the value), 1 an array and 2 an
6
- // object (`node` is {v, up}: the value and its parent's node, to detect cycles). Returns the
7
- // number of values then their tags and numbers, their strings and keys as one text (lengths
8
- // in UTF-16 code units), and the nodes of the nested arrays and objects. In an object,
9
- // each value is followed by the length of its key. An array or object of more than `whole`
10
- // values is returned as its JSON text instead (a cycle back to an ancestor passes through it
11
- // again, so JSON.stringify sees it).
12
- export function jlensLevel(node, kind, whole) {
13
- const nums = [0];
5
+ // Reads values: with `kind` 0 the input itself (`node` is the value); with 1 the array or
6
+ // object of the node `node[index]`, the nodes of a level; with 2 the item `n` of that array.
7
+ // A node is {v, up}: an array or object and its parent's node, to detect cycles. Returns the
8
+ // numbers, starting with twice the number of values, plus 1 for the fields of an object (a
9
+ // second leading number made this function half as slow again in V8), then each value's tag
10
+ // and number; the strings and keys as one text (lengths in UTF-16 code units); and the nodes
11
+ // of the nested arrays and objects. In an object, each value is followed by the length of its
12
+ // key. An array or object of more than `n` values is returned as its JSON text instead (a
13
+ // cycle back to an ancestor passes through it again, so JSON.stringify sees it).
14
+ export function jlensRead(node, kind, index, n) {
15
+ const nums = [2];
14
16
  let text = "";
15
17
  const nested = [];
16
- const up = kind === 0 ? null : node;
18
+ const up = kind === 0 ? null : node[index];
17
19
  const put = (v, key) => {
18
20
  if ((typeof v === "object" && v !== null) || typeof v === "bigint") {
19
21
  const toJSON = v.toJSON;
@@ -56,18 +58,20 @@ export function jlensLevel(node, kind, whole) {
56
58
  };
57
59
  if (kind === 0) {
58
60
  put(node, "");
59
- } else if (kind === 1) {
60
- const items = node.v;
61
- if (items.length > whole) return JSON.stringify(items);
62
- nums[0] = items.length;
61
+ } else if (kind === 2) {
62
+ if (!put(up.v[n], String(n))) nums.push(1);
63
+ } else if (Array.isArray(up.v)) {
64
+ const items = up.v;
65
+ if (items.length > n) return JSON.stringify(items);
66
+ nums[0] = items.length * 2;
63
67
  for (let i = 0; i < items.length; i++) {
64
68
  if (!put(items[i], String(i))) nums.push(1);
65
69
  }
66
70
  } else {
67
- const fields = node.v;
71
+ const fields = up.v;
68
72
  const keys = Object.keys(fields);
69
- if (keys.length > whole) return JSON.stringify(fields);
70
- nums[0] = keys.length;
73
+ if (keys.length > n) return JSON.stringify(fields);
74
+ nums[0] = keys.length * 2 + 1;
71
75
  for (const key of keys) {
72
76
  if (put(fields[key], key)) {
73
77
  nums.push(key.length);
@@ -77,3 +81,8 @@ export function jlensLevel(node, kind, whole) {
77
81
  }
78
82
  return [new Float64Array(nums), text, nested];
79
83
  }
84
+
85
+ // The length of the array of the node `nodes[index]`.
86
+ export function jlensLength(nodes, index) {
87
+ return nodes[index].v.length;
88
+ }