@ygracs/xobj-lib-js 0.2.9-b.2 → 0.3.0-beta.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/CHANGELOG.md CHANGED
@@ -1,13 +1,14 @@
1
- #### *v0.2.x*
1
+ #### *v0.3.x*
2
2
 
3
3
  Release version.
4
4
 
5
5
  > - update `xObj.md`;
6
6
  > - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.3.3;
7
+ > - change behavior for function: `addXObjElement` on handling exceptions;
7
8
  > - change behavior for function: `evalKeyName` on handling `opt` parameter;
8
9
  > - change behavior for function: `writeXObjParamRaw`, `writeXObjAttrRaw`;
9
10
  > - improve behavior for function: `writeXObjParam`, `writeXObjParamEx`, `writeXObjAttr`, `writeXObjAttrEx`;
10
- > - add a new function: `clearXObjNode`;
11
+ > - add a new function: `addXObjElementEx`, `clearXObjNode`;
11
12
  > - add a new `EvalKeyNameError` class;
12
13
  > - add new `compact`-property for `TXmlContentParseOptions`;
13
14
  > - some fixes.
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
- |***rev.*:**|0.1.2|
1
+ |***rev.*:**|0.1.3|
2
2
  |:---|---:|
3
- |***date***:|2024-09-15|
3
+ |***date***:|2026-02-28|
4
4
 
5
5
  ## Introduction
6
6
 
7
- This module provide a helper functions for object manipulation. It was primarily written to work with a XML-parse provided by a [`xml-js`](https://www.npmjs.com/package/xml-js) module for 'Node.js' running in "compact" mode.
7
+ This module provide a helper functions for object manipulation. It was primarily written to work with a XML-parser provided by a [`xml-js`](https://www.npmjs.com/package/xml-js) module for 'Node.js' running in "compact" mode.
8
8
 
9
- > Note: for more see `xObj.md` in the project `doc` directory.
9
+ > Note: for more see `xObj.md` in the package `doc` directory or in a package [*repo*](https://gitlab.com/ygracs/xobj-lib-js).
10
10
 
11
- > Notes on upgrade to `v0.2.0`
12
- > > The `v0.2.0` is not fully compatible with a previous one due to some breaking changes. For more details read the docs for a functions used in your project.
11
+ > Notes on upgrade to `v0.3.0`
12
+ > > The `v0.3.0` is not fully compatible with a previous one due to some breaking changes. For more details read the docs for a functions used in your project.
13
13
 
14
14
  ## Use cases
15
15
 
package/doc/xObj.md CHANGED
@@ -1,6 +1,6 @@
1
- >|***rev.*:**|0.1.48|
1
+ >|***rev.*:**|0.1.51|
2
2
  >|:---|---:|
3
- >|date:|2026-02-22|
3
+ >|date:|2026-02-28|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -886,6 +886,27 @@ The function throws a `TypeError` exception in case:
886
886
  <a name="addXObjElement"></a>
887
887
  #### **addXObjElement(object, name)** => `object`
888
888
 
889
+ This function adds an element given by `name` parameter to a members of the given object. If succeed the element will be returned or `null` in opposite.
890
+
891
+ ##### ***parameters***
892
+
893
+ | parameter name | value type | default value | description |
894
+ |:---|---|---:|:---|
895
+ | `object` | `object` | --- | some object |
896
+ | `name` | `string` | --- | some child element ID |
897
+
898
+ ##### ***exceptions***
899
+
900
+ The function throws a `TypeError` exception in case:
901
+
902
+ - code: `ERR_XOBJ_NPOBJ`
903
+ + if `object` parameter is not an `Object` instance;
904
+
905
+ <a name="addXObjElementEx"></a>
906
+ #### **addXObjElementEx(object, name)** => `object`
907
+
908
+ > since: \[v0.2.0]
909
+
889
910
  This function adds an element given by `name` parameter to a members of the given object and returns an `object` that represents a status of the operation.
890
911
 
891
912
  ##### ***parameters***
package/index.d.ts CHANGED
@@ -1,79 +1,107 @@
1
- declare const _exports: {
2
- readXObjParamRaw: typeof import("./lib/xObj-lib").readXObjParamRaw;
3
- readXObjParam: typeof import("./lib/xObj-lib").readXObjParam;
4
- readXObjParamAsBool: typeof import("./lib/xObj-lib").readXObjParamAsBool;
5
- readXObjParamAsNum: typeof import("./lib/xObj-lib").readXObjParamAsNum;
6
- readXObjParamEx: typeof import("./lib/xObj-lib").readXObjParamEx;
7
- readXObjParamAsIndex: typeof import("./lib/xObj-lib").readXObjParamAsIndex;
8
- writeXObjParamRaw: typeof import("./lib/xObj-lib").writeXObjParamRaw;
9
- writeXObjParam: typeof import("./lib/xObj-lib").writeXObjParam;
10
- writeXObjParamAsBool: typeof import("./lib/xObj-lib").writeXObjParamAsBool;
11
- writeXObjParamAsNum: typeof import("./lib/xObj-lib").writeXObjParamAsNum;
12
- writeXObjParamAsIndex: typeof import("./lib/xObj-lib").writeXObjParamAsIndex;
13
- writeXObjParamEx: typeof import("./lib/xObj-lib").writeXObjParamEx;
14
- readXObjAttrRaw: typeof import("./lib/xObj-lib").readXObjAttrRaw;
15
- readXObjAttr: typeof import("./lib/xObj-lib").readXObjAttr;
16
- readXObjAttrAsBool: typeof import("./lib/xObj-lib").readXObjAttrAsBool;
17
- readXObjAttrAsNum: typeof import("./lib/xObj-lib").readXObjAttrAsNum;
18
- readXObjAttrEx: typeof import("./lib/xObj-lib").readXObjAttrEx;
19
- readXObjAttrAsIndex: typeof import("./lib/xObj-lib").readXObjAttrAsIndex;
20
- writeXObjAttrRaw: typeof import("./lib/xObj-lib").writeXObjAttrRaw;
21
- writeXObjAttr: typeof import("./lib/xObj-lib").writeXObjAttr;
22
- writeXObjAttrAsBool: typeof import("./lib/xObj-lib").writeXObjAttrAsBool;
23
- writeXObjAttrAsNum: typeof import("./lib/xObj-lib").writeXObjAttrAsNum;
24
- writeXObjAttrAsIndex: typeof import("./lib/xObj-lib").writeXObjAttrAsIndex;
25
- writeXObjAttrEx: typeof import("./lib/xObj-lib").writeXObjAttrEx;
26
- getXObjAttributes: typeof import("./lib/xObj-lib").getXObjAttributes;
27
- checkXObjAttribute: typeof import("./lib/xObj-lib").checkXObjAttribute;
28
- deleteXObjAttribute: typeof import("./lib/xObj-lib").deleteXObjAttribute;
29
- renameXObjAttribute: typeof import("./lib/xObj-lib").renameXObjAttribute;
30
- getXObjElement: typeof import("./lib/xObj-lib").getXObjElement;
31
- addXObjElement: typeof import("./lib/xObj-lib").addXObjElement;
32
- insertXObjElement: typeof import("./lib/xObj-lib").insertXObjElement;
33
- insertXObjElementEx: typeof import("./lib/xObj-lib").insertXObjElementEx;
34
- deleteXObjElement: typeof import("./lib/xObj-lib").deleteXObjElement;
35
- deleteXObjElementEx: typeof import("./lib/xObj-lib").deleteXObjElementEx;
36
- renameXObjElement: typeof import("./lib/xObj-lib").renameXObjElement;
37
- evalXObjEName: typeof import("./lib/xObj-lib").evalXObjEName;
38
- insertXObjEList: typeof import("./lib/xObj-lib").insertXObjEList;
39
- insertXObjEListEx: typeof import("./lib/xObj-lib").insertXObjEListEx;
40
- evalKeyName: typeof import("./lib/xObj-lib").evalKeyName;
41
- genXObjENameDescr: typeof import("./lib/xObj-lib").genXObjENameDescr;
42
- insertXObjElements: typeof import("./lib/xObj-lib").insertXObjElements;
43
- insertXObjEChain: typeof import("./lib/xObj-lib").insertXObjEChain;
44
- clearXObjNode: typeof import("./lib/xObj-lib").clearXObjNode;
45
-
46
- TXmlContentParseOptions: typeof TXmlContentParseOptions; // [?] class declaration
47
- DEF_XML_PARSE_OPTIONS: typeof DEF_XML_PARSE_OPTIONS;
48
- XOBJ_DEF_TNAMES: typeof XOBJ_DEF_TNAMES;
49
-
50
- EvalKeyNameError: typeof EvalKeyNameError; // [?] class declaration
51
-
52
- xml2jsParseOptions: xml2jsParseOptions;
53
- js2xmlParseOptions: js2xmlParseOptions;
54
- OPT_parserOptions: OPT_parserOptions;
55
-
56
- XObjENameDescr: XObjENameDescr;
57
- OPT_inselops_L: OPT_inselops_L;
58
- OPT_inselops_S: OPT_inselops_S;
59
- RVAL_reason: RVAL_reason;
60
- RVAL_emodif: RVAL_emodif;
61
- VCOR_evalkname: VCOR_evalkname;
62
- };
63
- export = _exports;
64
1
  import { TXmlContentParseOptions } from "./lib/xObj-defs";
65
2
  import { DEF_XML_PARSE_OPTIONS } from "./lib/xObj-defs";
66
3
  import { XOBJ_DEF_TNAMES } from "./lib/xObj-defs";
67
- import { EvalKeyNameError } from "./lib/xObj-errors";
4
+
5
+ export {
6
+ TXmlContentParseOptions,
7
+ DEF_XML_PARSE_OPTIONS,
8
+ XOBJ_DEF_TNAMES,
9
+ };
68
10
 
69
11
  import type {
70
12
  xml2jsParseOptions, js2xmlParseOptions,
71
13
  OPT_parserOptions,
72
14
  } from "./lib/xObj-defs";
73
15
 
16
+ export type {
17
+ xml2jsParseOptions, js2xmlParseOptions,
18
+ OPT_parserOptions,
19
+ };
20
+
21
+ import { EvalKeyNameError } from "./lib/xObj-errors";
22
+
23
+ export { EvalKeyNameError };
24
+
25
+ import {
26
+ readXObjParamRaw,
27
+ readXObjParam,
28
+ readXObjParamEx,
29
+ readXObjParamAsBool, readXObjParamAsNum, readXObjParamAsIndex,
30
+ writeXObjParamRaw,
31
+ writeXObjParam,
32
+ writeXObjParamEx,
33
+ writeXObjParamAsBool, writeXObjParamAsNum, writeXObjParamAsIndex,
34
+ readXObjAttrRaw,
35
+ readXObjAttr,
36
+ readXObjAttrEx,
37
+ readXObjAttrAsBool, readXObjAttrAsNum, readXObjAttrAsIndex,
38
+ writeXObjAttrRaw,
39
+ writeXObjAttr,
40
+ writeXObjAttrEx,
41
+ writeXObjAttrAsBool, writeXObjAttrAsNum, writeXObjAttrAsIndex,
42
+ getXObjAttributes,
43
+ checkXObjAttribute,
44
+ deleteXObjAttribute,
45
+ renameXObjAttribute,
46
+ getXObjElement,
47
+ addXObjElement, addXObjElementEx,
48
+ insertXObjElement, insertXObjElementEx,
49
+ deleteXObjElement, deleteXObjElementEx,
50
+ renameXObjElement,
51
+ insertXObjEList, insertXObjEListEx,
52
+ evalXObjEName,
53
+ evalKeyName,
54
+ genXObjENameDescr,
55
+ insertXObjElements,
56
+ insertXObjEChain,
57
+ clearXObjNode,
58
+ } from "./lib/xObj-lib";
59
+
60
+ export {
61
+ readXObjParamRaw,
62
+ readXObjParam,
63
+ readXObjParamEx,
64
+ readXObjParamAsBool, readXObjParamAsNum, readXObjParamAsIndex,
65
+ writeXObjParamRaw,
66
+ writeXObjParam,
67
+ writeXObjParamEx,
68
+ writeXObjParamAsBool, writeXObjParamAsNum, writeXObjParamAsIndex,
69
+ readXObjAttrRaw,
70
+ readXObjAttr,
71
+ readXObjAttrEx,
72
+ readXObjAttrAsBool, readXObjAttrAsNum, readXObjAttrAsIndex,
73
+ writeXObjAttrRaw,
74
+ writeXObjAttr,
75
+ writeXObjAttrEx,
76
+ writeXObjAttrAsBool, writeXObjAttrAsNum, writeXObjAttrAsIndex,
77
+ getXObjAttributes,
78
+ checkXObjAttribute,
79
+ deleteXObjAttribute,
80
+ renameXObjAttribute,
81
+ getXObjElement,
82
+ addXObjElement, addXObjElementEx,
83
+ insertXObjElement, insertXObjElementEx,
84
+ deleteXObjElement, deleteXObjElementEx,
85
+ renameXObjElement,
86
+ insertXObjEList, insertXObjEListEx,
87
+ evalXObjEName,
88
+ evalKeyName,
89
+ genXObjENameDescr,
90
+ insertXObjElements,
91
+ insertXObjEChain,
92
+ clearXObjNode,
93
+ };
94
+
74
95
  import type {
75
96
  XObjENameDescr,
76
97
  OPT_inselops_L, OPT_inselops_S,
77
98
  RVAL_reason, RVAL_emodif,
78
99
  VCOR_evalkname,
79
100
  } from "./lib/xObj-lib";
101
+
102
+ export type {
103
+ XObjENameDescr,
104
+ OPT_inselops_L, OPT_inselops_S,
105
+ RVAL_reason, RVAL_emodif,
106
+ VCOR_evalkname,
107
+ };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.014-20251228]
1
+ // [v0.1.015-20260227]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -12,16 +12,66 @@ const {
12
12
  EvalKeyNameError,
13
13
  } = require('./lib/xObj-errors');
14
14
 
15
+ const xObj = require('./lib/xObj-lib');
16
+
15
17
  // === module inner block ===
16
18
 
17
19
  // === module main block ===
18
20
 
19
21
  // === module exports block ===
20
22
 
21
- module.exports = require('./lib/xObj-lib');
23
+ //module.exports = require('./lib/xObj-lib');
22
24
 
23
25
  module.exports.TXmlContentParseOptions = TXmlContentParseOptions;
24
26
  module.exports.DEF_XML_PARSE_OPTIONS = DEF_XML_PARSE_OPTIONS;
25
27
  module.exports.XOBJ_DEF_TNAMES = XOBJ_DEF_TNAMES;
26
28
 
27
29
  module.exports.EvalKeyNameError = EvalKeyNameError;
30
+
31
+ module.exports.readXObjParamRaw = xObj.readXObjParamRaw;
32
+ module.exports.readXObjParam = xObj.readXObjParam;
33
+ module.exports.readXObjParamAsBool = xObj.readXObjParamAsBool;
34
+ module.exports.readXObjParamAsNum = xObj.readXObjParamAsNum;
35
+ module.exports.readXObjParamEx = xObj.readXObjParamEx;
36
+ module.exports.readXObjParamAsIndex = xObj.readXObjParamAsIndex;
37
+ module.exports.writeXObjParamRaw = xObj.writeXObjParamRaw;
38
+ module.exports.writeXObjParam = xObj.writeXObjParam;
39
+ module.exports.writeXObjParamAsBool = xObj.writeXObjParamAsBool;
40
+ module.exports.writeXObjParamAsNum = xObj.writeXObjParamAsNum;
41
+ module.exports.writeXObjParamAsIndex = xObj.writeXObjParamAsIndex;
42
+ module.exports.writeXObjParamEx = xObj.writeXObjParamEx;
43
+
44
+ module.exports.readXObjAttrRaw = xObj.readXObjAttrRaw;
45
+ module.exports.readXObjAttr = xObj.readXObjAttr;
46
+ module.exports.readXObjAttrAsBool = xObj.readXObjAttrAsBool;
47
+ module.exports.readXObjAttrAsNum = xObj.readXObjAttrAsNum;
48
+ module.exports.readXObjAttrEx = xObj.readXObjAttrEx;
49
+ module.exports.readXObjAttrAsIndex = xObj.readXObjAttrAsIndex;
50
+ module.exports.writeXObjAttrRaw = xObj.writeXObjAttrRaw;
51
+ module.exports.writeXObjAttr = xObj.writeXObjAttr;
52
+ module.exports.writeXObjAttrAsBool = xObj.writeXObjAttrAsBool;
53
+ module.exports.writeXObjAttrAsNum = xObj.writeXObjAttrAsNum;
54
+ module.exports.writeXObjAttrAsIndex = xObj.writeXObjAttrAsIndex;
55
+ module.exports.writeXObjAttrEx = xObj.writeXObjAttrEx;
56
+
57
+ module.exports.getXObjAttributes = xObj.getXObjAttributes;
58
+ module.exports.checkXObjAttribute = xObj.checkXObjAttribute;
59
+ module.exports.deleteXObjAttribute = xObj.deleteXObjAttribute;
60
+ module.exports.renameXObjAttribute = xObj.renameXObjAttribute;
61
+
62
+ module.exports.getXObjElement = xObj.getXObjElement;
63
+ module.exports.addXObjElement = xObj.addXObjElement;
64
+ module.exports.addXObjElementEx = xObj.addXObjElementEx;
65
+ module.exports.insertXObjElement = xObj.insertXObjElement;
66
+ module.exports.insertXObjElementEx = xObj.insertXObjElementEx;
67
+ module.exports.deleteXObjElement = xObj.deleteXObjElement;
68
+ module.exports.deleteXObjElementEx = xObj.deleteXObjElementEx;
69
+ module.exports.renameXObjElement = xObj.renameXObjElement;
70
+
71
+ module.exports.evalXObjEName = xObj.evalXObjEName;
72
+ module.exports.insertXObjEList = xObj.insertXObjEList;
73
+ module.exports.insertXObjEListEx = xObj.insertXObjEListEx;
74
+
75
+ module.exports.genXObjENameDescr = xObj.genXObjENameDescr;
76
+ module.exports.insertXObjElements = xObj.insertXObjElements;
77
+ module.exports.insertXObjEChain = xObj.insertXObjEChain;
@@ -80,8 +80,8 @@ export namespace XOBJ_DEF_TNAMES {
80
80
  export const DEF_XML_PARSE_OPTIONS: OPT_parserOptions;
81
81
 
82
82
  /**
83
- * @classdesc Implements a container that provide a functionality to work
84
- * with options for an XML-parser
83
+ * Implements a container that provide a functionality to work
84
+ * with options for an XML-parser
85
85
  */
86
86
  export class TXmlContentParseOptions {
87
87
  /**
@@ -98,6 +98,7 @@ export class TXmlContentParseOptions {
98
98
  get settings(): OPT_parserOptions;
99
99
  /**
100
100
  * Returns a value of `compact` option
101
+ * @since 0.3.0
101
102
  */
102
103
  get compact(): boolean;
103
104
  /**
package/lib/xObj-defs.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.070-20260221]
1
+ // [v0.1.070-20260227]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -145,7 +145,7 @@ class TXmlContentParseOptions {
145
145
 
146
146
  /**
147
147
  * Returns a value of `compact` option
148
- * @since 0.2.x
148
+ * @since 0.3.0
149
149
  * @type {boolean}
150
150
  */
151
151
  get compact() {
@@ -13,8 +13,9 @@ export namespace XOBJ_ECODE_TABLE {
13
13
  export { XOBJ_TE_KNES_ECODE };
14
14
  }
15
15
  /**
16
- * @classdesc Extends a base `TypeError` object to provide some information
17
- * on the errors thrown when a key name evaluation failed
16
+ * Extends a base `TypeError` object to provide some information
17
+ * on the errors thrown when a key name evaluation failed
18
+ * @since 0.3.0
18
19
  */
19
20
  export class EvalKeyNameError extends TypeError {
20
21
  /**
@@ -1,4 +1,4 @@
1
- // [v0.1.004-20260221]
1
+ // [v0.1.004-20260227]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -41,7 +41,7 @@ const XOBJ_ECODE_TABLE = {
41
41
  module.exports.XOBJ_ECODE_TABLE = XOBJ_ECODE_TABLE;
42
42
 
43
43
  /**
44
- * @since 0.2.x
44
+ * @since 0.3.0
45
45
  * @augments TypeError
46
46
  * @classdesc Extends a base `TypeError` object to provide some information
47
47
  * on the errors thrown when a key name evaluation failed
package/lib/xObj-lib.d.ts CHANGED
@@ -110,6 +110,13 @@ export type OPT_inselops_S = {
110
110
  ripOldies?: boolean;
111
111
  };
112
112
 
113
+ /**
114
+ * Adds an element addressed by its key to a given object.
115
+ * @since 0.3.0
116
+ * @throws {TypeError} if `obj` param is not an object
117
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
118
+ */
119
+ export function addXObjElementEx(obj: object, name: string): RVAL_emodif;
113
120
  /**
114
121
  * Clears a given node
115
122
  * @throws {TypeError} if `node`-param is not an object or array
@@ -117,184 +124,185 @@ export type OPT_inselops_S = {
117
124
  export function clearXObjNode(node: object | object[]): boolean;
118
125
  /**
119
126
  * Extracts a parameter 'AS IS' from a given object.
120
- * @throws {TypeError} if first param is not an object
121
- * @throws {EvalKeyNameError} if second param is not valid identifier
127
+ * @throws {TypeError} if `obj` param is not an object
128
+ * @throws {EvalKeyNameError} if `key` param is not valid identifier
122
129
  */
123
130
  export function readXObjParamRaw(obj: object, key?: string): any;
124
131
  /**
125
132
  * Extracts a parameter from a given object and returns it as a string.
126
- * @throws {TypeError} if first param is not an object
133
+ * @throws {TypeError} if `obj` param is not an object
127
134
  */
128
135
  export function readXObjParam(obj: object, key?: string): string;
129
136
  /**
130
137
  * Extracts a parameter from a given object and returns it as a boolean.
131
- * @throws {TypeError} if first param is not an object
138
+ * @throws {TypeError} if `obj` param is not an object
132
139
  */
133
140
  export function readXObjParamAsBool(obj: object, defValue?: boolean, key?: string): boolean;
134
141
  /**
135
142
  * Extracts a parameter from a given object and returns it as a number.
136
- * @throws {TypeError} if first param is not an object
143
+ * @throws {TypeError} if `obj` param is not an object
137
144
  */
138
145
  export function readXObjParamAsNum(obj: object, defValue?: number, key?: string): number;
139
146
  /**
140
147
  * Extracts a parameter from a given object and returns it as a string.
141
- * @throws {TypeError} if first param is not an object
148
+ * @throws {TypeError} if `obj` param is not an object
142
149
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
143
150
  */
144
151
  export function readXObjParamEx(obj: object, opt?: object, key?: string): string;
145
152
  /**
146
153
  * Extracts a parameter from a given object and returns it as 'index' value.
147
- * @throws {TypeError} if first param is not an object
154
+ * @throws {TypeError} if `obj` param is not an object
148
155
  */
149
156
  export function readXObjParamAsIndex(obj: object, key?: string): number;
150
157
  /**
151
158
  * Writes a parameter 'AS IS' into a given object.
152
- * @throws {TypeError} if first param is not an object
153
- * @throws {EvalKeyNameError} if third param is not valid identifier
159
+ * @throws {TypeError} if `obj` param is not an object
160
+ * @throws {EvalKeyNameError} if `key` param is not valid identifier
154
161
  */
155
162
  export function writeXObjParamRaw(obj: object, value: any, key?: string): boolean;
156
163
  /**
157
164
  * Tries to convert a given value to a string and writes it as a parameter
158
165
  * into a given object.
159
- * @throws {TypeError} if first param is not an object
166
+ * @throws {TypeError} if `obj` param is not an object
160
167
  */
161
168
  export function writeXObjParam(obj: object, value: any, key?: string): boolean;
162
169
  /**
163
170
  * Tries to convert a given value to a boolean and writes it as a parameter
164
171
  * into a given object.
165
- * @throws {TypeError} if first param is not an object
172
+ * @throws {TypeError} if `obj` param is not an object
166
173
  */
167
174
  export function writeXObjParamAsBool(obj: object, value: any, defValue?: boolean, key?: string): boolean;
168
175
  /**
169
176
  * Tries to convert a given value to a number and writes it as a parameter
170
177
  * into a given object.
171
- * @throws {TypeError} if first param is not an object
178
+ * @throws {TypeError} if `obj` param is not an object
172
179
  */
173
180
  export function writeXObjParamAsNum(obj: object, value: any, defValue?: number, key?: string): boolean;
174
181
  /**
175
182
  * Tries to convert a given value into an 'index' value and writes it
176
183
  * as a parameter into a given object.
177
- * @throws {TypeError} if first param is not an object
184
+ * @throws {TypeError} if `obj` param is not an object
178
185
  */
179
186
  export function writeXObjParamAsIndex(obj: object, value: any, key?: string): boolean;
180
187
  /**
181
188
  * Tries to convert a given value to a string and writes it
182
189
  * as a parameter into a given object.
183
- * @throws {TypeError} if first param is not an object
190
+ * @throws {TypeError} if `obj` param is not an object
184
191
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
185
192
  */
186
193
  export function writeXObjParamEx(obj: object, value: any, opt?: object, key?: string): boolean;
187
194
  /**
188
195
  * Extracts an attribute 'AS IS' from a given object.
189
- * @throws {TypeError} if first param is not an object
190
- * @throws {EvalKeyNameError} if second param is not valid identifier
196
+ * @throws {TypeError} if `obj` param is not an object
197
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
191
198
  */
192
199
  export function readXObjAttrRaw(obj: object, attr?: string, key?: string): any;
193
200
  /**
194
201
  * Extracts an attribute from a given object and returns it as a string.
195
- * @throws {TypeError} if first param is not an object
202
+ * @throws {TypeError} if `obj` param is not an object
196
203
  */
197
204
  export function readXObjAttr(obj: object, attr: string, key?: string): string;
198
205
  /**
199
206
  * Extracts an attribute from a given object and returns it as a boolean.
200
- * @throws {TypeError} if first param is not an object
207
+ * @throws {TypeError} if `obj` param is not an object
201
208
  */
202
209
  export function readXObjAttrAsBool(obj: object, attr: string, defValue?: boolean, key?: string): boolean;
203
210
  /**
204
211
  * Extracts an attribute from a given object and returns it as a number.
205
212
  * @returns {number}
206
- * @throws {TypeError} if first param is not an object
213
+ * @throws {TypeError} if `obj` param is not an object
207
214
  */
208
215
  export function readXObjAttrAsNum(obj: object, attr: string, defValue?: number, key?: string): number;
209
216
  /**
210
217
  * Extracts an attribute from a given object and returns it as a string.
211
- * @throws {TypeError} if first param is not an object
218
+ * @throws {TypeError} if `obj` param is not an object
212
219
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
213
220
  */
214
221
  export function readXObjAttrEx(obj: object, attr: string, opt?: object, key?: string): string;
215
222
  /**
216
223
  * Extracts an attribute from a given object and returns it as 'index' value.
217
- * @throws {TypeError} if first param is not an object
224
+ * @throws {TypeError} if `obj` param is not an object
218
225
  */
219
226
  export function readXObjAttrAsIndex(obj: object, attr: string, key?: string): number;
220
227
  /**
221
228
  * Writes a parameter into a given object.
222
- * @throws {TypeError} if first param is not an object
223
- * @throws {EvalKeyNameError} if second param is not valid identifier
229
+ * @throws {TypeError} if `obj` param is not an object
230
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
224
231
  */
225
232
  export function writeXObjAttrRaw(obj: object, attr: string, value: any, key?: string): boolean;
226
233
  /**
227
234
  * Tries to convert a given value to a string and writes it as an attribute
228
235
  * into a given object.
229
- * @throws {TypeError} if first param is not an object
236
+ * @throws {TypeError} if `obj` param is not an object
230
237
  */
231
238
  export function writeXObjAttr(obj: object, attr: string, value: any, key?: string): boolean;
232
239
  /**
233
240
  * Tries to convert a given value to a boolean and writes it as an attribute
234
241
  * into a given object.
235
- * @throws {TypeError} if first param is not an object
242
+ * @throws {TypeError} if `obj` param is not an object
236
243
  */
237
244
  export function writeXObjAttrAsBool(obj: object, attr: string, value: any, defValue?: boolean, key?: string): boolean;
238
245
  /**
239
246
  * Tries to convert a given value to a number and writes it as an attribute
240
247
  * into a given object.
241
- * @throws {TypeError} if first param is not an object
248
+ * @throws {TypeError} if `obj` param is not an object
242
249
  */
243
250
  export function writeXObjAttrAsNum(obj: object, attr: string, value: any, defValue?: number, key?: string): boolean;
244
251
  /**
245
252
  * Tries to convert a given value into an 'index' value and writes it
246
253
  * as an attribute into a given object.
247
- * @throws {TypeError} if first param is not an object
254
+ * @throws {TypeError} if `obj` param is not an object
248
255
  */
249
256
  export function writeXObjAttrAsIndex(obj: object, attr: string, value: any, key?: string): boolean;
250
257
  /**
251
258
  * Tries to convert a given value to a string and writes it as an attribute
252
259
  * into a given object.
253
- * @throws {TypeError} if first param is not an object
260
+ * @throws {TypeError} if `obj` param is not an object
254
261
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
255
262
  */
256
263
  export function writeXObjAttrEx(obj: object, attr: string, value: any, opt?: object, key?: string): boolean;
257
264
  /**
258
265
  * Extracts an attributes from a given object by its key.
259
- * @throws {TypeError} if first param is not an object
266
+ * @throws {TypeError} if `obj` param is not an object
260
267
  */
261
268
  export function getXObjAttributes(obj: object, key?: string): object | null;
262
269
  /**
263
270
  * Checks whether an attribute is exists.
264
- * @throws {TypeError} if first param is not an object
265
- * @throws {EvalKeyNameError} if second param is not valid identifier
271
+ * @throws {TypeError} if `obj` param is not an object
272
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
266
273
  */
267
274
  export function checkXObjAttribute(obj: object, attr?: string, key?: string): boolean;
268
275
  /**
269
276
  * Deletes an attribute addressed by a given name.
270
- * @throws {TypeError} if first param is not an object
271
- * @throws {EvalKeyNameError} if second param is not valid identifier
277
+ * @throws {TypeError} if `obj` param is not an object
278
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
272
279
  */
273
280
  export function deleteXObjAttribute(obj: object, attr?: string, key?: string): boolean;
274
281
  /**
275
282
  * Renames an attribute addressed by a given name.
276
283
  * @since 0.2.0
277
- * @throws {TypeError} if first param is not an object
278
- * @throws {EvalKeyNameError} if second param is not valid identifier
279
- * @throws {EvalKeyNameError} if third param is not valid identifier
280
- * @throws {EvalKeyNameError} if forth param is not valid identifier
284
+ * @throws {TypeError} if `obj` param is not an object
285
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
286
+ * @throws {EvalKeyNameError} if `value` param is not valid identifier
287
+ * @throws {EvalKeyNameError} if `key` param is not valid identifier
281
288
  */
282
289
  export function renameXObjAttribute(obj: object, attr?: string, value?: string, key?: string): boolean;
283
290
  /**
284
291
  * Extracts an element from a given object by its key.
285
- * @throws {TypeError} if first param is not an object
286
- * @throws {EvalKeyNameError} if second param is not valid identifier
292
+ * @throws {TypeError} if `obj` param is not an object
293
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
287
294
  */
288
295
  export function getXObjElement(obj: object, name: string): any | null;
289
296
  /**
290
297
  * Adds an element addressed by its key to a given object.
291
- * @throws {TypeError} if first param is not an object
292
- * @throws {EvalKeyNameError} if second param is not valid identifier
298
+ * @throws {TypeError} if `obj` param is not an object
299
+ * @see {@link addXObjElementEx} for param details
293
300
  */
294
- export function addXObjElement(obj: object, name: string): RVAL_emodif;
301
+ export function addXObjElement(...args: addXObjElementParams): object | null;
302
+ type addXObjElementParams = Parameters<typeof addXObjElementEx>;
295
303
  /**
296
304
  * Inserts an element addressed by its key into a given object.
297
- * @throws {TypeError} if first param is not an object
305
+ * @throws {TypeError} if `obj` param is not an object
298
306
  * @see {@link insertXObjElementEx} for param details
299
307
  */
300
308
  export function insertXObjElement(...args: insertXObjElementParams): object | null;
@@ -302,28 +310,28 @@ type insertXObjElementParams = Parameters<typeof insertXObjElementEx>;
302
310
  /**
303
311
  * Inserts an element addressed by its key into a given object.
304
312
  * @since 0.2.0
305
- * @throws {TypeError} if first param is not an object
306
- * @throws {EvalKeyNameError} if second param is not valid identifier
313
+ * @throws {TypeError} if `obj` param is not an object
314
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
307
315
  */
308
316
  export function insertXObjElementEx(obj: object, name: string, opt?: OPT_inselops_L): RVAL_emodif;
309
317
  /**
310
318
  * Deletes an element addressed by its key from a given object.
311
- * @throws {TypeError} if first param is not an object
319
+ * @throws {TypeError} if `obj` param is not an object
312
320
  * @see {@link deleteXObjElementEx} for param details
313
321
  */
314
322
  export function deleteXObjElement(...args: deleteXObjElementParams): boolean;
315
323
  type deleteXObjElementParams = Parameters<typeof deleteXObjElementEx>;
316
324
  /**
317
325
  * Deletes an element addressed by its key from a given object.
318
- * @throws {TypeError} if first param is not an object
319
- * @throws {EvalKeyNameError} if second param is not valid identifier
326
+ * @throws {TypeError} if `obj` param is not an object
327
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
320
328
  */
321
329
  export function deleteXObjElementEx(obj: object, name: string): RVAL_emodif;
322
330
  /**
323
331
  * Renames an element addressed by its key.
324
- * @throws {TypeError} if first param is not an object
325
- * @throws {EvalKeyNameError} if second param is not valid identifier
326
- * @throws {EvalKeyNameError} if third param is not valid identifier
332
+ * @throws {TypeError} if `obj` param is not an object
333
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
334
+ * @throws {EvalKeyNameError} if `value` param is not valid identifier
327
335
  */
328
336
  export function renameXObjElement(obj: object, name?: string, value?: string): boolean;
329
337
  /**
@@ -332,7 +340,7 @@ export function renameXObjElement(obj: object, name?: string, value?: string): b
332
340
  export function evalXObjEName(value: any): null | number | string;
333
341
  /**
334
342
  * Inserts a list elements into a given object.
335
- * @throws {TypeError} if first param is not an object
343
+ * @throws {TypeError} if `obj` param is not an object
336
344
  * @see insertXObjEListEx
337
345
  */
338
346
  export function insertXObjEList(...args: insertXObjEListParams): object | object[] | null;
@@ -340,8 +348,8 @@ type insertXObjEListParams = Parameters<typeof insertXObjEListEx>;
340
348
  /**
341
349
  * Inserts a list elements into a given object.
342
350
  * @since 0.2.0
343
- * @throws {TypeError} if first param is not an object
344
- * @throws {EvalKeyNameError} if second param is not valid identifier
351
+ * @throws {TypeError} if `obj` param is not an object
352
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
345
353
  */
346
354
  export function insertXObjEListEx(obj: object, name: string, opt?: OPT_inselops_S): RVAL_emodif;
347
355
  /**
@@ -355,12 +363,12 @@ export function evalKeyName(value: any, opt?: boolean | IEvalKeyNameOptions): IE
355
363
  export function genXObjENameDescr(value: any): XObjENameDescr;
356
364
  /**
357
365
  * Inserts an elements into a given object.
358
- * @throws {TypeError} if first param is not an object
366
+ * @throws {TypeError} if `obj` param is not an object
359
367
  */
360
368
  export function insertXObjElements(obj: object, ...args: any[]): number;
361
369
  /**
362
370
  * Inserts a chain of an elements into a given object.
363
- * @throws {TypeError} if first param is not an object
371
+ * @throws {TypeError} if `obj` param is not an object
364
372
  */
365
373
  export function insertXObjEChain(obj: object, ...args: any[]): any | null;
366
374
  export {}
package/lib/xObj-lib.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.3.127-20260222]
1
+ // [v0.3.131-20260228]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -46,14 +46,14 @@ const {
46
46
 
47
47
  /**
48
48
  * An options setting for `evalKeyName` function
49
- * @since 0.2.x
49
+ * @since 0.3.0
50
50
  * @typedef {Object} IEvalKeyNameOptions
51
51
  * @property {boolean} [onlyNES] - a flag to accept only a non-empty string values
52
52
  */
53
53
 
54
54
  /**
55
55
  * A result of `evalKeyName` function if succeed
56
- * @since 0.2.x
56
+ * @since 0.3.0
57
57
  * @typedef {Object} IEvalKeyNameResultOnSuccess
58
58
  * @property {true} isSucceed - ops flag
59
59
  * @property {string} value - result value
@@ -61,7 +61,7 @@ const {
61
61
 
62
62
  /**
63
63
  * A result of `evalKeyName` function if failed
64
- * @since 0.2.x
64
+ * @since 0.3.0
65
65
  * @typedef {Object} IEvalKeyNameResultOnFail
66
66
  * @property {false} isSucceed - ops flag
67
67
  * @property {RVAL_reason} value - reason of fail
@@ -69,7 +69,7 @@ const {
69
69
 
70
70
  /**
71
71
  * A result of `evalKeyName` function
72
- * @since 0.2.x
72
+ * @since 0.3.0
73
73
  * @typedef {(IEvalKeyNameResultOnSuccess|IEvalKeyNameResultOnFail)} IEvalKeyNameResult
74
74
  */
75
75
 
@@ -78,7 +78,7 @@ const {
78
78
  * @typedef {Object} VCOR_evalkname
79
79
  * @property {boolean} isSucceed - ops flag
80
80
  * @property {(string|RVAL_reason)} value - result value or reson if failed
81
- * @todo \[from v0.2.x] make obsolete. Use `IEvalKeyNameResult` instead.
81
+ * @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameResult` instead.
82
82
  */
83
83
 
84
84
  /**
@@ -178,6 +178,7 @@ function evalXObjEName(value) {
178
178
  * @function genXObjENameDescr
179
179
  * @param {any} value - element name pattern
180
180
  * @returns {XObjENameDescr}
181
+ * @experimental
181
182
  */
182
183
  function genXObjENameDescr(value) {
183
184
  let result = null;
@@ -236,8 +237,8 @@ function genXObjENameDescr(value) {
236
237
  * @param {object} obj - some object
237
238
  * @param {string} name - some child element
238
239
  * @returns {?any}
239
- * @throws {TypeError} if first param is not an object
240
- * @throws {EvalKeyNameError} if second param is not valid identifier
240
+ * @throws {TypeError} if `obj` param is not an object
241
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
241
242
  */
242
243
  function getXObjElement(obj, name) {
243
244
  if (!isPlainObject(obj)) {
@@ -261,7 +262,7 @@ function getXObjElement(obj, name) {
261
262
  * @param {object} obj - some object
262
263
  * @param {string} [key=XOBJ_DEF_ATTR_TNAME] - some key
263
264
  * @returns {?object}
264
- * @throws {TypeError} if first param is not an object
265
+ * @throws {TypeError} if `obj` param is not an object
265
266
  */
266
267
  function getXObjAttributes(obj, key = XOBJ_DEF_ATTR_TNAME) {
267
268
  let result = null;
@@ -293,11 +294,39 @@ function getXObjAttributes(obj, key = XOBJ_DEF_ATTR_TNAME) {
293
294
  * @function addXObjElement
294
295
  * @param {object} obj - some object
295
296
  * @param {string} name - some child element
297
+ * @returns {?object}
298
+ * @throws {TypeError} if `obj` param is not an object
299
+ * @see {@link addXObjElementEx} for param details
300
+ */
301
+ function addXObjElement(...args) {
302
+ let item = null;
303
+ try {
304
+ ({ item } = addXObjElementEx(...args));
305
+ } catch (err) {
306
+ switch (err.code) {
307
+ case XOBJ_TE_NSTR_ECODE :
308
+ case XOBJ_TE_KNES_ECODE : {
309
+ break;
310
+ }
311
+ default: {
312
+ throw err;
313
+ }
314
+ };
315
+ };
316
+ return item;
317
+ };
318
+
319
+ /**
320
+ * Adds an element addressed by its key to a given object.
321
+ * @since 0.3.0
322
+ * @function addXObjElementEx
323
+ * @param {object} obj - some object
324
+ * @param {string} name - some child element
296
325
  * @returns {RVAL_emodif}
297
- * @throws {TypeError} if first param is not an object
298
- * @throws {EvalKeyNameError} if second param is not valid identifier
326
+ * @throws {TypeError} if `obj` param is not an object
327
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
299
328
  */
300
- function addXObjElement(obj, name) {
329
+ function addXObjElementEx(obj, name) {
301
330
  if (!isPlainObject(obj)) {
302
331
  throw new EvalKeyNameError(
303
332
  XOBJ_TE_NPOBJ_EMSG,
@@ -331,6 +360,7 @@ function addXObjElement(obj, name) {
331
360
  throw new EvalKeyNameError(msg, { code });
332
361
  };
333
362
  };
363
+ module.exports.addXObjElementEx = addXObjElementEx;
334
364
 
335
365
  /**
336
366
  * An options for an element insertion ops
@@ -347,7 +377,7 @@ function addXObjElement(obj, name) {
347
377
  * @param {string} name - some child element
348
378
  * @param {OPT_inselops_L} [opt] - options
349
379
  * @returns {?object}
350
- * @throws {TypeError} if first param is not an object
380
+ * @throws {TypeError} if `obj` param is not an object
351
381
  * @see {@link insertXObjElementEx} for param details
352
382
  */
353
383
  function insertXObjElement(...args) {
@@ -376,8 +406,8 @@ function insertXObjElement(...args) {
376
406
  * @param {string} name - some child element
377
407
  * @param {OPT_inselops_L} [opt] - options
378
408
  * @returns {RVAL_emodif}
379
- * @throws {TypeError} if first param is not an object
380
- * @throws {EvalKeyNameError} if second param is not valid identifier
409
+ * @throws {TypeError} if `obj` param is not an object
410
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
381
411
  */
382
412
  function insertXObjElementEx(obj, name, opt) {
383
413
  if (!isPlainObject(obj)) {
@@ -427,7 +457,7 @@ function insertXObjElementEx(obj, name, opt) {
427
457
  * @param {object} obj - some object
428
458
  * @param {string} name - some child element
429
459
  * @returns {boolean}
430
- * @throws {TypeError} if first param is not an object
460
+ * @throws {TypeError} if `obj` param is not an object
431
461
  * @see {@link deleteXObjElementEx} for param details
432
462
  */
433
463
  function deleteXObjElement(...args) {
@@ -454,8 +484,8 @@ function deleteXObjElement(...args) {
454
484
  * @param {object} obj - some object
455
485
  * @param {string} name - some child element
456
486
  * @returns {RVAL_emodif}
457
- * @throws {TypeError} if first param is not an object
458
- * @throws {EvalKeyNameError} if second param is not valid identifier
487
+ * @throws {TypeError} if `obj` param is not an object
488
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
459
489
  */
460
490
  function deleteXObjElementEx(obj, name) {
461
491
  if (!isPlainObject(obj)) {
@@ -487,9 +517,9 @@ function deleteXObjElementEx(obj, name) {
487
517
  * @param {string} name - some child element
488
518
  * @param {string} value - new element ID
489
519
  * @returns {boolean}
490
- * @throws {TypeError} if first param is not an object
491
- * @throws {EvalKeyNameError} if second param is not valid identifier
492
- * @throws {EvalKeyNameError} if third param is not valid identifier
520
+ * @throws {TypeError} if `obj` param is not an object
521
+ * @throws {EvalKeyNameError} if `name` param is not valid identifier
522
+ * @throws {EvalKeyNameError} if `value` param is not valid identifier
493
523
  */
494
524
  function renameXObjElement(obj, name = '', value = '') {
495
525
  if (!isPlainObject(obj)) {
@@ -532,8 +562,8 @@ function renameXObjElement(obj, name = '', value = '') {
532
562
  * @param {string} attr - some attribute ID
533
563
  * @param {string} [key] - some key
534
564
  * @returns {boolean}
535
- * @throws {TypeError} if first param is not an object
536
- * @throws {EvalKeyNameError} if second param is not valid identifier
565
+ * @throws {TypeError} if `obj` param is not an object
566
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
537
567
  */
538
568
  function checkXObjAttribute(obj, attr = '', key) {
539
569
  let _obj = null;
@@ -560,8 +590,8 @@ function checkXObjAttribute(obj, attr = '', key) {
560
590
  * @param {string} attr - some attribute ID
561
591
  * @param {string} [key] - some key
562
592
  * @returns {boolean}
563
- * @throws {TypeError} if first param is not an object
564
- * @throws {EvalKeyNameError} if second param is not valid identifier
593
+ * @throws {TypeError} if `obj` param is not an object
594
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
565
595
  */
566
596
  function deleteXObjAttribute(obj, attr = '', key) {
567
597
  let _obj = null;
@@ -594,10 +624,10 @@ function deleteXObjAttribute(obj, attr = '', key) {
594
624
  * @param {string} value - new attribute ID
595
625
  * @param {string} [key] - some key
596
626
  * @returns {boolean}
597
- * @throws {TypeError} if first param is not an object
598
- * @throws {EvalKeyNameError} if second param is not valid identifier
599
- * @throws {EvalKeyNameError} if third param is not valid identifier
600
- * @throws {EvalKeyNameError} if forth param is not valid identifier
627
+ * @throws {TypeError} if `obj` param is not an object
628
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
629
+ * @throws {EvalKeyNameError} if `value` param is not valid identifier
630
+ * @throws {EvalKeyNameError} if `key` param is not valid identifier
601
631
  */
602
632
  function renameXObjAttribute(obj, attr = '', value = '', key = XOBJ_DEF_ATTR_TNAME) {
603
633
  if (!isPlainObject(obj)) {
@@ -647,8 +677,8 @@ function renameXObjAttribute(obj, attr = '', value = '', key = XOBJ_DEF_ATTR_TNA
647
677
  * @param {object} obj - some object
648
678
  * @param {string} [key=XOBJ_DEF_PARAM_TNAME] - some key
649
679
  * @returns {any}
650
- * @throws {TypeError} if first param is not an object
651
- * @throws {EvalKeyNameError} if second param is not valid identifier
680
+ * @throws {TypeError} if `obj` param is not an object
681
+ * @throws {EvalKeyNameError} if `key` param is not valid identifier
652
682
  */
653
683
  function readXObjParamRaw(obj, key = XOBJ_DEF_PARAM_TNAME) {
654
684
  if (!isPlainObject(obj)) {
@@ -672,8 +702,8 @@ function readXObjParamRaw(obj, key = XOBJ_DEF_PARAM_TNAME) {
672
702
  * @param {any} value - some value
673
703
  * @param {string} [key=XOBJ_DEF_PARAM_TNAME] - some key
674
704
  * @returns {boolean}
675
- * @throws {TypeError} if first param is not an object
676
- * @throws {EvalKeyNameError} if third param is not valid identifier
705
+ * @throws {TypeError} if `obj` param is not an object
706
+ * @throws {EvalKeyNameError} if `key` param is not valid identifier
677
707
  */
678
708
  function writeXObjParamRaw(obj, value, key = XOBJ_DEF_PARAM_TNAME) {
679
709
  if (!isPlainObject(obj)) {
@@ -707,8 +737,8 @@ function writeXObjParamRaw(obj, value, key = XOBJ_DEF_PARAM_TNAME) {
707
737
  * @param {string} attr - some attribute
708
738
  * @param {string} [key] - some key
709
739
  * @returns {any}
710
- * @throws {TypeError} if first param is not an object
711
- * @throws {EvalKeyNameError} if second param is not valid identifier
740
+ * @throws {TypeError} if `obj` param is not an object
741
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
712
742
  */
713
743
  function readXObjAttrRaw(obj, attr = '', key) {
714
744
  let _obj = null;
@@ -735,8 +765,8 @@ function readXObjAttrRaw(obj, attr = '', key) {
735
765
  * @param {any} value - some value
736
766
  * @param {string} [key=XOBJ_DEF_ATTR_TNAME] - some key
737
767
  * @returns {boolean}
738
- * @throws {TypeError} if first param is not an object
739
- * @throws {EvalKeyNameError} if second param is not valid identifier
768
+ * @throws {TypeError} if `obj` param is not an object
769
+ * @throws {EvalKeyNameError} if `attr` param is not valid identifier
740
770
  */
741
771
  function writeXObjAttrRaw(obj, attr = '', value, key = XOBJ_DEF_ATTR_TNAME) {
742
772
  const { isSucceed, value: name } = evalKeyName(attr, false);
@@ -782,7 +812,7 @@ function writeXObjAttrRaw(obj, attr = '', value, key = XOBJ_DEF_ATTR_TNAME) {
782
812
  * @param {object} obj - some object
783
813
  * @param {string} [key] - some key
784
814
  * @returns {string}
785
- * @throws {TypeError} if first param is not an object
815
+ * @throws {TypeError} if `obj` param is not an object
786
816
  */
787
817
  function readXObjParam(obj, key) {
788
818
  const opt = {
@@ -807,7 +837,7 @@ function readXObjParam(obj, key) {
807
837
  * @param {boolean} [defValue] - default value
808
838
  * @param {string} [key] - some key
809
839
  * @returns {boolean}
810
- * @throws {TypeError} if first param is not an object
840
+ * @throws {TypeError} if `obj` param is not an object
811
841
  * @see readAsBoolEx from `@ygracs/bsfoc-lib-js` on details for result
812
842
  */
813
843
  function readXObjParamAsBool(obj, defValue, key) {
@@ -834,7 +864,7 @@ function readXObjParamAsBool(obj, defValue, key) {
834
864
  * @param {number} [defValue] - default value
835
865
  * @param {string} [key] - some key
836
866
  * @returns {number}
837
- * @throws {TypeError} if first param is not an object
867
+ * @throws {TypeError} if `obj` param is not an object
838
868
  * @see readAsNumberEx from `@ygracs/bsfoc-lib-js` on details for result
839
869
  */
840
870
  function readXObjParamAsNum(obj, defValue, key) {
@@ -861,7 +891,7 @@ function readXObjParamAsNum(obj, defValue, key) {
861
891
  * @param {object} [opt] - options
862
892
  * @param {string} [key] - some key
863
893
  * @returns {string}
864
- * @throws {TypeError} if first param is not an object
894
+ * @throws {TypeError} if `obj` param is not an object
865
895
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
866
896
  */
867
897
  function readXObjParamEx(obj, opt, key) {
@@ -894,7 +924,7 @@ function readXObjParamEx(obj, opt, key) {
894
924
  * @param {object} obj - some object
895
925
  * @param {string} [key] - some key
896
926
  * @returns {number}
897
- * @throws {TypeError} if first param is not an object
927
+ * @throws {TypeError} if `obj` param is not an object
898
928
  */
899
929
  function readXObjParamAsIndex(obj, key) {
900
930
  let result = undefined;
@@ -921,7 +951,7 @@ function readXObjParamAsIndex(obj, key) {
921
951
  * @param {any} value - some value
922
952
  * @param {string} [key] - some key
923
953
  * @returns {boolean}
924
- * @throws {TypeError} if first param is not an object
954
+ * @throws {TypeError} if `obj` param is not an object
925
955
  */
926
956
  function writeXObjParam(obj, value, key) {
927
957
  let isSucceed = false;
@@ -948,7 +978,7 @@ function writeXObjParam(obj, value, key) {
948
978
  * @param {boolean} [defValue] - default value
949
979
  * @param {string} [key] - some key
950
980
  * @returns {boolean}
951
- * @throws {TypeError} if first param is not an object
981
+ * @throws {TypeError} if `obj` param is not an object
952
982
  */
953
983
  function writeXObjParamAsBool(obj, value, defValue, key) {
954
984
  let isSucceed = false;
@@ -979,7 +1009,7 @@ function writeXObjParamAsBool(obj, value, defValue, key) {
979
1009
  * @param {number} [defValue] - default value
980
1010
  * @param {string} [key] - some key
981
1011
  * @returns {boolean}
982
- * @throws {TypeError} if first param is not an object
1012
+ * @throws {TypeError} if `obj` param is not an object
983
1013
  */
984
1014
  function writeXObjParamAsNum(obj, value, defValue, key) {
985
1015
  let isSucceed = false;
@@ -1009,7 +1039,7 @@ function writeXObjParamAsNum(obj, value, defValue, key) {
1009
1039
  * @param {any} value - some value
1010
1040
  * @param {string} [key] - some key
1011
1041
  * @returns {boolean}
1012
- * @throws {TypeError} if first param is not an object
1042
+ * @throws {TypeError} if `obj` param is not an object
1013
1043
  */
1014
1044
  function writeXObjParamAsIndex(obj, value, key) {
1015
1045
  let isSucceed = false;
@@ -1040,7 +1070,7 @@ function writeXObjParamAsIndex(obj, value, key) {
1040
1070
  * @param {object} [opt] - options
1041
1071
  * @param {string} [key] - some key
1042
1072
  * @returns {boolean}
1043
- * @throws {TypeError} if first param is not an object
1073
+ * @throws {TypeError} if `obj` param is not an object
1044
1074
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
1045
1075
  */
1046
1076
  function writeXObjParamEx(obj, value, opt, key) {
@@ -1084,7 +1114,7 @@ function writeXObjParamEx(obj, value, opt, key) {
1084
1114
  * @param {string} attr - some attribute
1085
1115
  * @param {string} [key] - some key
1086
1116
  * @returns {string}
1087
- * @throws {TypeError} if first param is not an object
1117
+ * @throws {TypeError} if `obj` param is not an object
1088
1118
  */
1089
1119
  function readXObjAttr(obj, attr, key) {
1090
1120
  const opt = {
@@ -1110,7 +1140,7 @@ function readXObjAttr(obj, attr, key) {
1110
1140
  * @param {boolean} [defValue] - default value
1111
1141
  * @param {string} [key] - some key
1112
1142
  * @returns {boolean}
1113
- * @throws {TypeError} if first param is not an object
1143
+ * @throws {TypeError} if `obj` param is not an object
1114
1144
  * @see readAsBoolEx from `@ygracs/bsfoc-lib-js` on details for result
1115
1145
  */
1116
1146
  function readXObjAttrAsBool(obj, attr, defValue, key) {
@@ -1138,7 +1168,7 @@ function readXObjAttrAsBool(obj, attr, defValue, key) {
1138
1168
  * @param {number} [defValue] - default value
1139
1169
  * @param {string} [key] - some key
1140
1170
  * @returns {number}
1141
- * @throws {TypeError} if first param is not an object
1171
+ * @throws {TypeError} if `obj` param is not an object
1142
1172
  * @see readAsNumberEx from `@ygracs/bsfoc-lib-js` on details for result
1143
1173
  */
1144
1174
  function readXObjAttrAsNum(obj, attr, defValue, key) {
@@ -1166,7 +1196,7 @@ function readXObjAttrAsNum(obj, attr, defValue, key) {
1166
1196
  * @param {object} [opt] - options
1167
1197
  * @param {string} [key] - some key
1168
1198
  * @returns {string}
1169
- * @throws {TypeError} if first param is not an object
1199
+ * @throws {TypeError} if `obj` param is not an object
1170
1200
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
1171
1201
  */
1172
1202
  function readXObjAttrEx(obj, attr, opt, key) {
@@ -1200,7 +1230,7 @@ function readXObjAttrEx(obj, attr, opt, key) {
1200
1230
  * @param {string} attr - some attribute
1201
1231
  * @param {string} [key] - some key
1202
1232
  * @returns {number}
1203
- * @throws {TypeError} if first param is not an object
1233
+ * @throws {TypeError} if `obj` param is not an object
1204
1234
  */
1205
1235
  function readXObjAttrAsIndex(obj, attr, key) {
1206
1236
  let result = undefined;
@@ -1228,7 +1258,7 @@ function readXObjAttrAsIndex(obj, attr, key) {
1228
1258
  * @param {any} value - some value
1229
1259
  * @param {string} [key] - some key
1230
1260
  * @returns {boolean}
1231
- * @throws {TypeError} if first param is not an object
1261
+ * @throws {TypeError} if `obj` param is not an object
1232
1262
  */
1233
1263
  function writeXObjAttr(obj, attr, value, key) {
1234
1264
  let isSucceed = false;
@@ -1256,7 +1286,7 @@ function writeXObjAttr(obj, attr, value, key) {
1256
1286
  * @param {boolean} [defValue] - default value
1257
1287
  * @param {string} [key] - some key
1258
1288
  * @returns {boolean}
1259
- * @throws {TypeError} if first param is not an object
1289
+ * @throws {TypeError} if `obj` param is not an object
1260
1290
  */
1261
1291
  function writeXObjAttrAsBool(obj, attr, value, defValue, key) {
1262
1292
  let isSucceed = false;
@@ -1288,7 +1318,7 @@ function writeXObjAttrAsBool(obj, attr, value, defValue, key) {
1288
1318
  * @param {number} [defValue] - default value
1289
1319
  * @param {string} [key] - some key
1290
1320
  * @returns {boolean}
1291
- * @throws {TypeError} if first param is not an object
1321
+ * @throws {TypeError} if `obj` param is not an object
1292
1322
  */
1293
1323
  function writeXObjAttrAsNum(obj, attr, value, defValue, key) {
1294
1324
  let isSucceed = false;
@@ -1319,7 +1349,7 @@ function writeXObjAttrAsNum(obj, attr, value, defValue, key) {
1319
1349
  * @param {any} value - some value
1320
1350
  * @param {string} [key] - some key
1321
1351
  * @returns {boolean}
1322
- * @throws {TypeError} if first param is not an object
1352
+ * @throws {TypeError} if `obj` param is not an object
1323
1353
  */
1324
1354
  function writeXObjAttrAsIndex(obj, attr, value, key) {
1325
1355
  let isSucceed = false;
@@ -1351,7 +1381,7 @@ function writeXObjAttrAsIndex(obj, attr, value, key) {
1351
1381
  * @param {object} [opt] - options
1352
1382
  * @param {string} [key] - some key
1353
1383
  * @returns {boolean}
1354
- * @throws {TypeError} if first param is not an object
1384
+ * @throws {TypeError} if `obj` param is not an object
1355
1385
  * @todo [since `v0.2.1`] deprecate use of `opt` as `string`
1356
1386
  */
1357
1387
  function writeXObjAttrEx(obj, attr, value, opt, key) {
@@ -1395,7 +1425,8 @@ function writeXObjAttrEx(obj, attr, value, opt, key) {
1395
1425
  * @param {...string} name - some child element name
1396
1426
  * @param {OPT_inselops_L} [opt]
1397
1427
  * @returns {number}
1398
- * @throws {TypeError} if first param is not an object
1428
+ * @throws {TypeError} if `obj` param is not an object
1429
+ * @experimental
1399
1430
  */
1400
1431
  function insertXObjElements(obj, ...args) {
1401
1432
  if (!isPlainObject(obj)) {
@@ -1431,7 +1462,7 @@ function insertXObjElements(obj, ...args) {
1431
1462
  * @param {string} name - some child element name
1432
1463
  * @param {OPT_inselops_S} [opt] - options
1433
1464
  * @returns {?(object|object[])}
1434
- * @throws {TypeError} if first param is not an object
1465
+ * @throws {TypeError} if `obj` param is not an object
1435
1466
  */
1436
1467
  function insertXObjEList(...args) {
1437
1468
  let item = null;
@@ -1459,8 +1490,8 @@ function insertXObjEList(...args) {
1459
1490
  * @param {string} name - some child element name
1460
1491
  * @param {OPT_inselops_S} [opt] - options
1461
1492
  * @returns {RVAL_emodif}
1462
- * @throws {TypeError} if first param is not an object
1463
- * @throws {EvalKeyNameError} if second param is not valid identifier
1493
+ * @throws {TypeError} if `obj` param is not an object
1494
+ * @throws {EvalKeyNameError} if `nmae` param is not valid identifier
1464
1495
  */
1465
1496
  function insertXObjEListEx(obj, name, opt) {
1466
1497
  if (!isPlainObject(obj)) {
@@ -1510,7 +1541,8 @@ function insertXObjEListEx(obj, name, opt) {
1510
1541
  * @param {...string} name - some child element name
1511
1542
  * @param {object} [opt] - options
1512
1543
  * @returns {?any}
1513
- * @throws {TypeError} if first param is not an object
1544
+ * @throws {TypeError} if `obj` param is not an object
1545
+ * @experimental
1514
1546
  */
1515
1547
  function insertXObjEChain(obj, ...args) {
1516
1548
  if (!isPlainObject(obj)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ygracs/xobj-lib-js",
3
- "version": "0.2.9-b.2",
3
+ "version": "0.3.0-beta.0",
4
4
  "description": "A helper library to work with xml-js module",
5
5
  "author": "ygracs <cs70th-om@rambler.ru>",
6
6
  "license": "MIT",