@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.
package/dist/index.cjs CHANGED
@@ -37,11 +37,14 @@ __export(src_exports, {
37
37
  expand: () => expand,
38
38
  fullize: () => fullize,
39
39
  generate: () => generate,
40
+ generateBits: () => generateBits,
40
41
  info: () => info,
41
42
  legacy: () => legacy_exports,
42
43
  lex: () => lex,
43
44
  optimize: () => optimize,
44
45
  parse: () => parse,
46
+ parseBits: () => parseBits,
47
+ patchEntry: () => patchEntry,
45
48
  splitBits: () => splitBits,
46
49
  transform: () => transform,
47
50
  transformParallel: () => transformParallel,
@@ -60,7 +63,7 @@ var import_node_module = require("module");
60
63
  // src/generated/package_info.ts
61
64
  var PACKAGE_INFO = {
62
65
  "name": "@gmb/bitmark-parser",
63
- "version": "6.1.4",
66
+ "version": "6.2.0",
64
67
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
65
68
  "license": "ISC",
66
69
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -100,7 +103,7 @@ function buildUnits(wasm2, input, inputIsBitmark) {
100
103
  if (isError(out)) throw new Error(out);
101
104
  const envelopes = JSON.parse(out);
102
105
  return envelopes.map((env, index) => ({
103
- view: { format: "json", index, total: envelopes.length, bit: env.bit },
106
+ view: { format: "json", index, total: envelopes.length, bit: env.bit ?? {} },
104
107
  // Per-bit transform consumes a one-bit JSON document.
105
108
  source: JSON.stringify([env])
106
109
  }));
@@ -1341,6 +1344,11 @@ var StringWriter = stubClass("StringWriter", INTERNAL_REASON);
1341
1344
  var FileWriter = stubClass("FileWriter", INTERNAL_REASON);
1342
1345
  var StreamWriter = stubClass("StreamWriter", INTERNAL_REASON);
1343
1346
 
1347
+ // src/types.ts
1348
+ function patchEntry(path2, op, value) {
1349
+ return value === void 0 ? { path: path2, op } : { path: path2, op, value };
1350
+ }
1351
+
1344
1352
  // src/index.ts
1345
1353
  var require2 = (0, import_node_module.createRequire)(importMetaUrl);
1346
1354
  var wasm = require2("../wasm/bitmark_wasm.js");
@@ -1354,6 +1362,19 @@ function lex(input, options = {}) {
1354
1362
  function parse(input, options = {}) {
1355
1363
  return wasm.parse(input, options.mode ?? "optimized");
1356
1364
  }
1365
+ function parseBits(input, options = {}) {
1366
+ const out = wasm.convert(input, "auto", "json", options.mode ?? "optimized", false, 2, 1);
1367
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1368
+ return JSON.parse(out);
1369
+ }
1370
+ function generateBits(bits, options = {}) {
1371
+ const entries = bits.map(
1372
+ (b) => b !== null && typeof b === "object" && "bit" in b && typeof b.bit === "object" ? b : { bit: b }
1373
+ );
1374
+ const out = wasm.convert(JSON.stringify(entries), "json", "bitmark", options.mode ?? "optimized", false, 2, 1);
1375
+ if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1376
+ return out;
1377
+ }
1357
1378
  function convert(input, options = {}) {
1358
1379
  return wasm.convert(
1359
1380
  input,
@@ -1439,11 +1460,14 @@ function generate(input, options = {}) {
1439
1460
  expand,
1440
1461
  fullize,
1441
1462
  generate,
1463
+ generateBits,
1442
1464
  info,
1443
1465
  legacy,
1444
1466
  lex,
1445
1467
  optimize,
1446
1468
  parse,
1469
+ parseBits,
1470
+ patchEntry,
1447
1471
  splitBits,
1448
1472
  transform,
1449
1473
  transformParallel,