xml-twig 1.5.0 → 1.6.1

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.
Files changed (3) hide show
  1. package/doc/twig.md +1 -0
  2. package/package.json +1 -1
  3. package/twig.js +9 -0
package/doc/twig.md CHANGED
@@ -1506,6 +1506,7 @@ Optional settings for the Twig parser
1506
1506
  | [trim] | <code>boolean</code> | If `true`, then turn any whitespace into a single space. Text and comments are trimmed. |
1507
1507
  | [resumeAfterError] | <code>boolean</code> | If `true` then parser continues reading after an error. Otherwise it throws exception. |
1508
1508
  | [partial] | <code>boolean</code> | If `true` then unhandled elements are purged. |
1509
+ | [file] | <code>string</code> | The filename to be parsed. Just used for information and logging purpose. |
1509
1510
 
1510
1511
  **Example**
1511
1512
  ```js
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "name": "xml-twig",
7
7
  "description": "Node module for processing huge XML documents in tree mode",
8
- "version": "1.5.0",
8
+ "version": "1.6.1",
9
9
  "main": "twig.js",
10
10
  "directories": {
11
11
  "doc": "doc"
package/twig.js CHANGED
@@ -63,6 +63,7 @@ const Any = new AnyHandler();
63
63
  * @property {boolean} [trim] - If `true`, then turn any whitespace into a single space. Text and comments are trimmed.
64
64
  * @property {boolean} [resumeAfterError] - If `true` then parser continues reading after an error. Otherwise it throws exception.
65
65
  * @property {boolean} [partial] - If `true` then unhandled elements are purged.
66
+ * @property {string} [file] - Optional. The name of file to be parsed. Just used for information and logging purpose.
66
67
  * @example { method: 'expat', xmlns: true }
67
68
  * @default { method: 'sax', xmlns: false, trim: true, resumeAfterError: false, partial: false }
68
69
  */
@@ -266,6 +267,14 @@ function createParser(handler, options = {}) {
266
267
  enumerable: true
267
268
  });
268
269
 
270
+ if (options.file != null) {
271
+ Object.defineProperty(parser, 'file', {
272
+ value: options.file,
273
+ writable: false,
274
+ enumerable: true
275
+ });
276
+ }
277
+
269
278
  // Common events
270
279
  parser.on('text', function (str) {
271
280
  if (current === undefined || current === null) return;