@cntwg/xml-lib-js 0.0.23 → 0.0.24

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ #### *v0.0.24*
2
+
3
+ Pre-release version.
4
+
5
+ > - `xmldoc-lib.md` updated;
6
+ > - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.4;
7
+ > - updated dependency on `@ygracs/xobj-lib-js` module to v0.1.0;
8
+ > - some fixes in `xmldoc-lib.js` module.
9
+
1
10
  #### *v0.0.23*
2
11
 
3
12
  Pre-release version.
package/README.md CHANGED
@@ -1,11 +1,21 @@
1
- |***rev.*:**|0.1.2|
1
+ |***rev.*:**|0.1.3|
2
2
  |:---|---:|
3
- |***date***:|2022-09-06|
3
+ |***date***:|2023-07-31|
4
4
 
5
5
  ## Introduction
6
6
 
7
7
  This module provide a base functionality for handling an XML-documents.
8
8
 
9
+ ## Use cases
10
+
11
+ ### Installation
12
+
13
+ `npm install @cntwg/xml-lib-js`
14
+
15
+ ## Description
16
+
17
+ This module contains the following components:
18
+
9
19
  ### 1. xObj-manipulator
10
20
 
11
21
  xObj-manipulator is a set of functions (see docs for [`@ygracs/xobj-lib-js` module](https://gitlab.com/ygracs/xobj-lib-js)).
package/doc/xmldoc-lib.md CHANGED
@@ -1,6 +1,6 @@
1
- >|***rev.*:**|0.1.20|
1
+ >|***rev.*:**|0.1.21|
2
2
  >|:---|---:|
3
- >|date:|2023-03-01|
3
+ >|date:|2023-07-31|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -37,11 +37,13 @@ The settings listed in the table below:
37
37
  |`trim`|`boolean`|`true`|
38
38
  |`spaces`|`number`|`2`|
39
39
 
40
+ > WARNING: The constant `DEF\_XML\_PARSE\_OPTIONS` will be deprecated. Use `XML\_DEF\_PARSE\_OPTIONS` instead.
41
+
40
42
  ### **DEF\_XML\_ROOT\_ETAG_NAME** or **XML\_DEF\_ROOT\_ETAG_NAME**
41
43
 
42
44
  This constant defines a default value for naming the root element for XML-document. Its value is `root`.
43
45
 
44
- > WARNING: The constant `DEF\_XML\_ROOT\_ETAG_NAME` will be deprecated. Use `XML\_DEF\_ROOT\_ETAG_NAME` instead.
46
+ > WARNING: The constant `DEF\_XML\_ROOT\_ETAG_NAME` is deprecate. Use `XML\_DEF\_ROOT\_ETAG_NAME` instead.
45
47
 
46
48
  ## Module classes
47
49
 
@@ -305,6 +307,12 @@ This method deletes an element addressed by `index`. If succeed `true` is return
305
307
 
306
308
  This method loaded a list of elements listed by `items` and returns a quantity of a successfully added elements.
307
309
 
310
+ The `options` structure is listed below:
311
+
312
+ |option name|value type|default value|description|
313
+ |:---|---|---:|:---|
314
+ |`useClear`|`boolean`|`true`|if `true` the method deletes all the previous content before load the list|
315
+
308
316
  #### class methods (*special*)
309
317
 
310
318
  ##### **_getItemRaw(name)**
@@ -461,3 +469,5 @@ This method returns a document content as a string in the JSON-format.
461
469
  ##### **_bindContent(obj\[, options])**
462
470
 
463
471
  This method binds a given object as a document content.
472
+
473
+ For `options` parameter details see the class constractor description.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.009-20230316]
1
+ // [v0.1.010-20230731]
2
2
 
3
3
  // === module init block ===
4
4
 
package/lib/xmldoc-lib.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.066-20230317]
1
+ // [v0.1.067-20230731]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -584,11 +584,14 @@ class TXmlElementsListController {
584
584
  }
585
585
 
586
586
  loadItems(items, opt){
587
- let act_as_new = true;
588
- if (isPlainObject(opt)) {
589
- act_as_new = readAsBool(opt.load_as_new, act_as_new);
590
- };
591
- if (act_as_new) this.clear();
587
+ const _options = isPlainObject(opt) ? opt : {};
588
+ let {
589
+ useClear,
590
+ load_as_new,
591
+ } = _options;
592
+ if (useClear === undefined) useClear = load_as_new;
593
+ if (typeof useClear !== 'boolean') useClear = true;
594
+ if (useClear) this.clear();
592
595
  let count = this.count;
593
596
  valueToArray(items).forEach((item) => { this.addItem(item); });
594
597
  return this.count - count;
@@ -609,11 +612,11 @@ class TXmlContentDeclaration {
609
612
  // load options
610
613
  let _options = isPlainObject(opt) ? opt : {};
611
614
  // set parser options
612
- let { parseOptions: parseOptions } = _options;
615
+ let { parseOptions } = _options;
613
616
  if (!isPlainObject(parseOptions)) {
614
617
  _options.parseOptions = parseOptions = {};
615
618
  };
616
- let { settings: settings } = parseOptions;
619
+ let { settings } = parseOptions;
617
620
  if (!isPlainObject(settings)) parseOptions.settings = settings = {};
618
621
  let { declarationKey } = settings;
619
622
  if (
@@ -1059,9 +1062,6 @@ class TXmlContentContainer {
1059
1062
 
1060
1063
  // === module exports block ===
1061
1064
 
1062
- //exports.DEF_XML_PARSE_OPTIONS = XML_DEF_PARSE_OPTIONS; // will deprecate
1063
- //exports.DEF_XML_ROOT_ETAG_NAME = XML_DEF_ROOT_ETAG_NAME; // will deprecate
1064
-
1065
1065
  exports.XML_DEF_PARSE_OPTIONS = XML_DEF_PARSE_OPTIONS;
1066
1066
  exports.XML_DEF_ROOT_ETAG_NAME = XML_DEF_ROOT_ETAG_NAME;
1067
1067
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntwg/xml-lib-js",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "A library for handling an XML-documents",
5
5
  "author": "ygracs <cs70th-om@rambler.ru>",
6
6
  "license": "MIT",
@@ -32,9 +32,9 @@
32
32
  "#lib/*": "./lib/*"
33
33
  },
34
34
  "dependencies": {
35
- "@ygracs/bsfoc-lib-js": "^0.1.3",
35
+ "@ygracs/bsfoc-lib-js": "^0.1.4",
36
36
  "@ygracs/xml-js6": "^0.0.3-b",
37
- "@ygracs/xobj-lib-js": "^0.0.14-rc4"
37
+ "@ygracs/xobj-lib-js": "^0.1.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "jest": "^29.6.1",