@gmb/bitmark-parser 6.1.4 → 6.2.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.
Binary file
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  countBits: () => countBits,
29
29
  expand: () => expand,
30
30
  fullize: () => fullize2,
31
+ generateBits: () => generateBits,
31
32
  info: () => info2,
32
33
  init: () => init,
33
34
  initSync: () => initSync,
@@ -35,6 +36,8 @@ __export(index_exports, {
35
36
  lex: () => lex2,
36
37
  optimize: () => optimize2,
37
38
  parse: () => parse2,
39
+ parseBits: () => parseBits,
40
+ patchEntry: () => patchEntry,
38
41
  splitBits: () => splitBits,
39
42
  transform: () => transform2,
40
43
  transformParallel: () => transformParallel,
@@ -538,7 +541,7 @@ var bitmark_wasm_default = __wbg_init;
538
541
  // src/generated/package_info.ts
539
542
  var PACKAGE_INFO = {
540
543
  "name": "@gmb/bitmark-parser",
541
- "version": "6.1.4",
544
+ "version": "6.2.0",
542
545
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
543
546
  "license": "ISC",
544
547
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -578,7 +581,7 @@ function buildUnits(wasm2, input, inputIsBitmark) {
578
581
  if (isError(out)) throw new Error(out);
579
582
  const envelopes = JSON.parse(out);
580
583
  return envelopes.map((env, index) => ({
581
- view: { format: "json", index, total: envelopes.length, bit: env.bit },
584
+ view: { format: "json", index, total: envelopes.length, bit: env.bit ?? {} },
582
585
  // Per-bit transform consumes a one-bit JSON document.
583
586
  source: JSON.stringify([env])
584
587
  }));
@@ -1785,6 +1788,11 @@ var StringWriter = stubClass("StringWriter", INTERNAL_REASON);
1785
1788
  var FileWriter = stubClass("FileWriter", INTERNAL_REASON);
1786
1789
  var StreamWriter = stubClass("StreamWriter", INTERNAL_REASON);
1787
1790
 
1791
+ // src/types.ts
1792
+ function patchEntry(path, op, value) {
1793
+ return value === void 0 ? { path, op } : { path, op, value };
1794
+ }
1795
+
1788
1796
  // src/browser/index.ts
1789
1797
  setLegacyWasm(bitmark_wasm_exports);
1790
1798
  async function init(module_or_path) {
@@ -1802,6 +1810,19 @@ function lex2(input, options = {}) {
1802
1810
  function parse2(input, options = {}) {
1803
1811
  return parse(input, options.mode ?? "optimized");
1804
1812
  }
1813
+ function parseBits(input, options = {}) {
1814
+ const out = convert(input, "auto", "json", options.mode ?? "optimized", false, 2, 1);
1815
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1816
+ return JSON.parse(out);
1817
+ }
1818
+ function generateBits(bits, options = {}) {
1819
+ const entries = bits.map(
1820
+ (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1821
+ );
1822
+ const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
1823
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1824
+ return out;
1825
+ }
1805
1826
  function convert2(input, options = {}) {
1806
1827
  return convert(
1807
1828
  input,
@@ -1883,6 +1904,7 @@ function info2(options = {}) {
1883
1904
  countBits,
1884
1905
  expand,
1885
1906
  fullize,
1907
+ generateBits,
1886
1908
  info,
1887
1909
  init,
1888
1910
  initSync,
@@ -1890,6 +1912,8 @@ function info2(options = {}) {
1890
1912
  lex,
1891
1913
  optimize,
1892
1914
  parse,
1915
+ parseBits,
1916
+ patchEntry,
1893
1917
  splitBits,
1894
1918
  transform,
1895
1919
  transformParallel,