@gmb/bitmark-parser-generator 3.25.1 → 3.25.2

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.
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable */
3
3
  export const buildInfo = {
4
4
  "name": "@gmb/bitmark-parser-generator",
5
- "version": "3.25.1",
5
+ "version": "3.25.2",
6
6
  "author": "Get More Brain Ltd",
7
7
  "license": "ISC",
8
8
  "description": "A bitmark parser and generator using Peggy.js"
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // https://peggyjs.org/
4
4
  import { Breakscape } from "../../../breakscaping/Breakscape";
5
- const VERSION = "8.32.1";
5
+ const VERSION = "8.32.2";
6
6
  //Parser peggy.js
7
7
  // parser options (parameter when running parser):
8
8
  // allowedStartRules: ["bitmarkPlusPlus", "bitmarkPlus", "bitmarkMinusMinus", "bitmarkPlusString", "bitmarkMinusMinusString"]
@@ -129,32 +129,34 @@ function removeTempParsingParent(obj) {
129
129
  // }
130
130
  // return node;
131
131
  // }
132
+ /**
133
+ * RAS 2025-05-22
134
+ * Fixes / features
135
+ * - Handles arrays or objects as input (including root array) - main reason for change
136
+ * - Modifies in-place rather than copying array.
137
+ * - Removed some unnecessary checks - will work fine without them
138
+ */
132
139
  function cleanEmptyTextNodes(root) {
133
- // return root;
134
- const isEmptyTextNode = (n) => n &&
135
- typeof n === "object" &&
136
- n.type === "text" &&
137
- (n.text === "" || n.text == null); // catches null & undefined
138
- /** Recursively walk only through `content` arrays */
140
+ const isEmptyTextNode = (n) => n && n.type === "text" && !n.text;
141
+ // Recursively walk 'content' arrays
139
142
  function cleanContentArray(arr) {
140
143
  for (let i = arr.length - 1; i >= 0; i--) {
141
144
  const item = arr[i];
142
145
  if (isEmptyTextNode(item)) {
143
- arr.splice(i, 1); // drop the empty text node
146
+ // drop the empty text node
147
+ arr.splice(i, 1);
144
148
  }
145
- else if (item &&
146
- typeof item === "object" &&
147
- Array.isArray(item.content)) {
148
- cleanContentArray(item.content); // recurse into nested `content`
149
+ else if (item && Array.isArray(item.content)) {
150
+ // recurse into `content` array
151
+ cleanContentArray(item.content);
149
152
  }
150
153
  // Any other shape is ignored.
151
154
  }
152
155
  }
153
- // Kick-off: root may itself be an array or an object with `content`
154
156
  if (Array.isArray(root)) {
155
157
  cleanContentArray(root);
156
158
  }
157
- else if (root && typeof root === "object" && Array.isArray(root.content)) {
159
+ else if (root && Array.isArray(root.content)) {
158
160
  cleanContentArray(root.content);
159
161
  }
160
162
  return root;