@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.
@@ -497,7 +497,7 @@ var bitmark_wasm_default = __wbg_init;
497
497
  // src/generated/package_info.ts
498
498
  var PACKAGE_INFO = {
499
499
  "name": "@gmb/bitmark-parser",
500
- "version": "6.1.4",
500
+ "version": "6.2.0",
501
501
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
502
502
  "license": "ISC",
503
503
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -537,7 +537,7 @@ function buildUnits(wasm2, input, inputIsBitmark) {
537
537
  if (isError(out)) throw new Error(out);
538
538
  const envelopes = JSON.parse(out);
539
539
  return envelopes.map((env, index) => ({
540
- view: { format: "json", index, total: envelopes.length, bit: env.bit },
540
+ view: { format: "json", index, total: envelopes.length, bit: env.bit ?? {} },
541
541
  // Per-bit transform consumes a one-bit JSON document.
542
542
  source: JSON.stringify([env])
543
543
  }));
@@ -1744,6 +1744,11 @@ var StringWriter = stubClass("StringWriter", INTERNAL_REASON);
1744
1744
  var FileWriter = stubClass("FileWriter", INTERNAL_REASON);
1745
1745
  var StreamWriter = stubClass("StreamWriter", INTERNAL_REASON);
1746
1746
 
1747
+ // src/types.ts
1748
+ function patchEntry(path, op, value) {
1749
+ return value === void 0 ? { path, op } : { path, op, value };
1750
+ }
1751
+
1747
1752
  // src/browser/index.ts
1748
1753
  setLegacyWasm(bitmark_wasm_exports);
1749
1754
  async function init(module_or_path) {
@@ -1761,6 +1766,19 @@ function lex2(input, options = {}) {
1761
1766
  function parse2(input, options = {}) {
1762
1767
  return parse(input, options.mode ?? "optimized");
1763
1768
  }
1769
+ function parseBits(input, options = {}) {
1770
+ const out = convert(input, "auto", "json", options.mode ?? "optimized", false, 2, 1);
1771
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1772
+ return JSON.parse(out);
1773
+ }
1774
+ function generateBits(bits, options = {}) {
1775
+ const entries = bits.map(
1776
+ (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1777
+ );
1778
+ const out = convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
1779
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1780
+ return out;
1781
+ }
1764
1782
  function convert2(input, options = {}) {
1765
1783
  return convert(
1766
1784
  input,
@@ -1841,6 +1859,7 @@ export {
1841
1859
  countBits,
1842
1860
  expand,
1843
1861
  fullize2 as fullize,
1862
+ generateBits,
1844
1863
  info2 as info,
1845
1864
  init,
1846
1865
  initSync,
@@ -1848,6 +1867,8 @@ export {
1848
1867
  lex2 as lex,
1849
1868
  optimize2 as optimize,
1850
1869
  parse2 as parse,
1870
+ parseBits,
1871
+ patchEntry,
1851
1872
  splitBits,
1852
1873
  transform2 as transform,
1853
1874
  transformParallel,