@ygracs/xobj-lib-js 0.3.3 → 0.4.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,3 +1,10 @@
1
+ #### *v0.4.0*
2
+
3
+ Release version.
4
+
5
+ > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.4.0;
6
+ > - some fixes.
7
+
1
8
  #### *v0.3.3*
2
9
 
3
10
  Release version.
package/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { TXmlContentParseOptions } from "./lib/xObj-defs";
2
2
  import { DEF_XML_PARSE_OPTIONS } from "./lib/xObj-defs";
3
3
  import { XOBJ_DEF_TNAMES } from "./lib/xObj-defs";
4
+ import { EvalKeyNameError } from "./lib/xObj-errors";
5
+ import { evalXObjEName } from "./lib/xObj-names";
6
+ import { genXObjENameDescr } from "./lib/xObj-names";
4
7
 
5
8
  export {
6
9
  TXmlContentParseOptions,
@@ -8,6 +11,8 @@ export {
8
11
  XOBJ_DEF_TNAMES,
9
12
  };
10
13
 
14
+ export { EvalKeyNameError };
15
+
11
16
  import type {
12
17
  xml2jsParseOptions, js2xmlParseOptions,
13
18
  OPT_parserOptions,
@@ -18,10 +23,6 @@ export type {
18
23
  OPT_parserOptions,
19
24
  };
20
25
 
21
- import { EvalKeyNameError } from "./lib/xObj-errors";
22
-
23
- export { EvalKeyNameError };
24
-
25
26
  import {
26
27
  readXObjAttrRaw,
27
28
  readXObjAttr,
@@ -55,9 +56,6 @@ import {
55
56
  deleteXObjElement, deleteXObjElementEx,
56
57
  renameXObjElement,
57
58
  insertXObjEList, insertXObjEListEx,
58
- evalXObjEName,
59
- evalKeyName,
60
- genXObjENameDescr,
61
59
  insertXObjElements,
62
60
  insertXObjEChain,
63
61
  clearXObjNode,
@@ -91,7 +89,6 @@ export {
91
89
  renameXObjElement,
92
90
  insertXObjEList, insertXObjEListEx,
93
91
  evalXObjEName,
94
- evalKeyName,
95
92
  genXObjENameDescr,
96
93
  insertXObjElements,
97
94
  insertXObjEChain,
@@ -99,19 +96,18 @@ export {
99
96
  };
100
97
 
101
98
  import type {
102
- XObjENameDescr, XObjENameDescrConditions,
103
- OPT_inselops_L, OPT_inselops_S,
104
- RVAL_emodif,
105
- VCOR_evalkname, RVAL_reason,
99
+ IXObjENameDescr, IXObjENameDescrConditions,
106
100
  IEvalKeyNameResult,
101
+ } from "./lib/xObj-names";
102
+
103
+ import type {
104
+ OPT_inselops_L, OPT_inselops_S,
107
105
  INode,
108
106
  } from "./lib/xObj-lib";
109
107
 
110
108
  export type {
111
- XObjENameDescr, XObjENameDescrConditions,
109
+ IXObjENameDescr, IXObjENameDescrConditions,
112
110
  OPT_inselops_L, OPT_inselops_S,
113
- RVAL_emodif,
114
- VCOR_evalkname, RVAL_reason,
115
111
  IEvalKeyNameResult,
116
112
  INode,
117
113
  };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.017-20260606]
1
+ // [v0.1.019-20260630]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -12,6 +12,11 @@ const {
12
12
  EvalKeyNameError,
13
13
  } = require('./lib/xObj-errors');
14
14
 
15
+ const {
16
+ evalXObjEName,
17
+ genXObjENameDescr,
18
+ } = require('./lib/xObj-names');
19
+
15
20
  const xObjAttr = require('./lib/xObj-attr');
16
21
 
17
22
  const xObjParam = require('./lib/xObj-param');
@@ -30,6 +35,9 @@ module.exports.XOBJ_DEF_TNAMES = XOBJ_DEF_TNAMES;
30
35
 
31
36
  module.exports.EvalKeyNameError = EvalKeyNameError;
32
37
 
38
+ module.exports.evalXObjEName = evalXObjEName;
39
+ module.exports.genXObjENameDescr = genXObjENameDescr;
40
+
33
41
  module.exports.readXObjParamRaw = xObjParam.readXObjParamRaw;
34
42
  module.exports.readXObjParam = xObjParam.readXObjParam;
35
43
  module.exports.readXObjParamAsBool = xObjParam.readXObjParamAsBool;
@@ -70,11 +78,9 @@ module.exports.deleteXObjElement = xObj.deleteXObjElement;
70
78
  module.exports.deleteXObjElementEx = xObj.deleteXObjElementEx;
71
79
  module.exports.renameXObjElement = xObj.renameXObjElement;
72
80
 
73
- module.exports.evalXObjEName = xObj.evalXObjEName;
74
81
  module.exports.insertXObjEList = xObj.insertXObjEList;
75
82
  module.exports.insertXObjEListEx = xObj.insertXObjEListEx;
76
83
 
77
- module.exports.genXObjENameDescr = xObj.genXObjENameDescr;
78
84
  module.exports.insertXObjElements = xObj.insertXObjElements;
79
85
  module.exports.insertXObjEChain = xObj.insertXObjEChain;
80
86
 
package/lib/xObj-attr.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.3.140-20260607]
1
+ // [v0.3.141-20260629]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -21,6 +21,9 @@ const {
21
21
 
22
22
  const {
23
23
  evalKeyName,
24
+ } = require('./xObj-names');
25
+
26
+ const {
24
27
  getXObjElement, insertXObjElement,
25
28
  // * import types definitions *
26
29
  INode,
package/lib/xObj-lib.d.ts CHANGED
@@ -1,196 +1,102 @@
1
1
  /**
2
- * A result of `evalKeyName` function
2
+ * A `Node`-element
3
+ * @since 0.3.2
3
4
  */
4
- export type IEvalKeyNameResult = IEvalKeyNameResultOnSuccess | IEvalKeyNameResultOnFail;
5
- export const IEvalKeyNameResult: IEvalKeyNameResult;
6
5
  export type INode = {
7
6
  [x: string]: any;
8
7
  };
9
8
  export const INode: INode;
10
9
  /**
11
- * A result of an xObj modification ops
12
- */
13
- export type INodeModifResult = INodeModifResultOnFail | INodeModifResultOnSuccess;
14
- export const INodeModifResult: INodeModifResult;
15
- /**
16
- * Some conditions applied to an element as a result of an element name pattern
17
- * evaluation ops.
18
- */
19
- export type XObjENameDescrConditions = {
20
- /**
21
- * - element name
22
- */
23
- name: any;
24
- /**
25
- * - element type
26
- */
27
- type: any;
28
- /**
29
- * - some value
30
- */
31
- value?: any;
32
- };
33
- /**
34
- * A result of an element name pattern evaluation ops.
10
+ * A result of an xObj modification ops if failed
35
11
  */
36
- export type XObjENameDescr = {
37
- /**
38
- * - ops flag
39
- */
40
- isERR: boolean;
12
+ export type INodeModifResultOnFail = {
41
13
  /**
42
- * - element name
14
+ * - flag that indicates whether an ops is succeed or not
43
15
  */
44
- name: null | number | string;
16
+ isSucceed: false;
45
17
  /**
46
- * - some conditions applied to an element
18
+ * - some element as a result
47
19
  */
48
- conditions: XObjENameDescrConditions | null;
49
- };
50
- /**
51
- * A list of a `INode`-elements
52
- */
53
- export type INodeList = INode[];
54
- /**
55
- * An options for an element insertion ops
56
- */
57
- export type OPT_inselops_L = {
58
- force?: boolean;
59
- ripOldies?: boolean;
60
- acceptIfList?: boolean;
61
- };
62
- /**
63
- * An options for an element insertion ops
64
- */
65
- export type OPT_inselops_S = {
66
- force?: boolean;
67
- ripOldies?: boolean;
20
+ item: null;
68
21
  };
22
+ export const INodeModifResultOnFail: INodeModifResultOnFail;
69
23
  /**
70
- * A result of a value check ops.
71
- * @deprecated
72
- * @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameReasonOnFail` instead.
24
+ * A result of an xObj modification ops if succeed (when child element returned)
73
25
  */
74
- export type RVAL_reason = {
26
+ export type INodeModifResultOnSuccess_S1 = {
75
27
  /**
76
- * - message ID
28
+ * - flag that indicates whether an ops is succeed or not
77
29
  */
78
- code: string;
30
+ isSucceed: true;
79
31
  /**
80
- * - message text
32
+ * - some element as a result
81
33
  */
82
- msg: string;
34
+ item: INode;
83
35
  };
36
+ export const INodeModifResultOnSuccess_S1: INodeModifResultOnSuccess_S1;
84
37
  /**
85
- * An error description of a value check ops on fail.
38
+ * A result of an xObj modification ops if succeed (when child element returned)
86
39
  */
87
- export type IEvalKeyNameReasonOnFail = {
40
+ export type INodeModifResultOnSuccess_S2 = {
88
41
  /**
89
- * - message ID
42
+ * - flag that indicates whether an ops is succeed or not
90
43
  */
91
- code: string;
44
+ isSucceed: true;
92
45
  /**
93
- * - message text
46
+ * - some element as a result
94
47
  */
95
- msg: string;
48
+ item: INode[];
96
49
  };
50
+ export const INodeModifResultOnSuccess_S2: INodeModifResultOnSuccess_S2;
97
51
  /**
98
- * A result of a value check ops.
99
- * @deprecated
100
- * @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameResult` instead.
52
+ * A result of an xObj modification ops if succeed (when child element not returned)
101
53
  */
102
- export type VCOR_evalkname = {
54
+ export type INodeModifResultOnSuccess_S0 = {
103
55
  /**
104
- * - ops flag
56
+ * - flag that indicates whether an ops is succeed or not
105
57
  */
106
- isSucceed: boolean;
58
+ isSucceed: true;
107
59
  /**
108
- * - result value or reson if failed
60
+ * - some element as a result
109
61
  */
110
- value: string | IEvalKeyNameReasonOnFail;
62
+ item: null;
111
63
  };
64
+ export const INodeModifResultOnSuccess_S0: INodeModifResultOnSuccess_S0;
112
65
  /**
113
- * An options setting for `evalKeyName` function
66
+ * A list of a `Node`-elements
114
67
  */
115
- export type IEvalKeyNameOptions = {
116
- /**
117
- * - a flag to accept only a non-empty string values
118
- */
119
- onlyNES?: boolean;
120
- };
68
+ export type INodeList = INode[];
121
69
  /**
122
- * A result of `evalKeyName` function if succeed
70
+ * A result of an xObj modification ops
71
+ * @since 0.4.0
123
72
  */
124
- export type IEvalKeyNameResultOnSuccess = {
125
- /**
126
- * - ops flag
127
- */
128
- isSucceed: true;
129
- /**
130
- * - result value
131
- */
132
- value: string;
133
- };
73
+ export type IAddNodeResult = INodeModifResultOnFail | INodeModifResultOnSuccess_S1;
134
74
  /**
135
- * A result of `evalKeyName` function if failed
75
+ * An options for an element insertion ops
136
76
  */
137
- export type IEvalKeyNameResultOnFail = {
138
- /**
139
- * - ops flag
140
- */
141
- isSucceed: false;
142
- /**
143
- * - reason of fail
144
- */
145
- value: IEvalKeyNameReasonOnFail;
77
+ export type OPT_inselops_L = {
78
+ force?: boolean;
79
+ ripOldies?: boolean;
80
+ acceptIfList?: boolean;
146
81
  };
147
82
  /**
148
83
  * A result of an xObj modification ops
149
- * @deprecated
150
- * @todo \[from v0.3.2] make obsolete. Use `INodeModifResult` instead.
84
+ * @since 0.4.0
151
85
  */
152
- export type RVAL_emodif = {
153
- /**
154
- * - flag that indicates whether an ops is succeed or not
155
- */
156
- isSucceed: boolean;
157
- /**
158
- * - some element as a result
159
- */
160
- item: object | object[] | null;
161
- };
86
+ export type IInsertNodeResult = INodeModifResultOnFail | INodeModifResultOnSuccess_S1 | INodeModifResultOnSuccess_S2;
162
87
  /**
163
- * A result of an xObj modification ops if failed
88
+ * A result of an xObj modification ops
89
+ * @since 0.4.0
164
90
  */
165
- export type INodeModifResultOnFail = {
166
- /**
167
- * - flag that indicates whether an ops is succeed or not
168
- */
169
- isSucceed: false;
170
- /**
171
- * - some element as a result
172
- */
173
- item: null;
174
- };
91
+ export type IDeleteNodeResult = INodeModifResultOnFail | INodeModifResultOnSuccess_S0 | INodeModifResultOnSuccess_S1 | INodeModifResultOnSuccess_S2;
175
92
  /**
176
- * A result of an xObj modification ops if succeed
93
+ * An options for an element insertion ops
177
94
  */
178
- export type INodeModifResultOnSuccess = {
179
- /**
180
- * - flag that indicates whether an ops is succeed or not
181
- */
182
- isSucceed: true;
183
- /**
184
- * - some element as a result
185
- */
186
- item: object | object[];
95
+ export type OPT_inselops_S = {
96
+ force?: boolean;
97
+ ripOldies?: boolean;
187
98
  };
188
99
 
189
- /**
190
- * Tries to convert a value into an ID.
191
- * @inner
192
- */
193
- export function evalKeyName(value: any, opt?: boolean | IEvalKeyNameOptions): IEvalKeyNameResult;
194
100
  /**
195
101
  * Extracts an element from a given object by its key.
196
102
  * @throws {TypeError} if `obj` param is not an object
@@ -202,7 +108,7 @@ export function getXObjElement(obj: INode, name: string): any | null;
202
108
  * @throws {TypeError} if `obj` param is not an object
203
109
  * @see {@link addXObjElementEx} for param details
204
110
  */
205
- export function addXObjElement(...args: addXObjElementParams): object | null;
111
+ export function addXObjElement(...args: addXObjElementParams): INode | null;
206
112
  type addXObjElementParams = Parameters<typeof addXObjElementEx>;
207
113
  /**
208
114
  * Adds an element addressed by its key to a given object.
@@ -210,13 +116,13 @@ type addXObjElementParams = Parameters<typeof addXObjElementEx>;
210
116
  * @throws {TypeError} if `obj` param is not an object
211
117
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
212
118
  */
213
- export function addXObjElementEx(obj: INode, name: string): INodeModifResult;
119
+ export function addXObjElementEx(obj: INode, name: string): IAddNodeResult;
214
120
  /**
215
121
  * Inserts an element addressed by its key into a given object.
216
122
  * @throws {TypeError} if `obj` param is not an object
217
123
  * @see {@link insertXObjElementEx} for param details
218
124
  */
219
- export function insertXObjElement(...args: insertXObjElementParams): object | null;
125
+ export function insertXObjElement(...args: insertXObjElementParams): INode | INode[] | null;
220
126
  type insertXObjElementParams = Parameters<typeof insertXObjElementEx>;
221
127
  /**
222
128
  * Inserts an element addressed by its key into a given object.
@@ -224,7 +130,7 @@ type insertXObjElementParams = Parameters<typeof insertXObjElementEx>;
224
130
  * @throws {TypeError} if `obj` param is not an object
225
131
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
226
132
  */
227
- export function insertXObjElementEx(obj: INode, name: string, opt?: OPT_inselops_L): INodeModifResult;
133
+ export function insertXObjElementEx(obj: INode, name: string, opt?: OPT_inselops_L): IInsertNodeResult;
228
134
  /**
229
135
  * Deletes an element addressed by its key from a given object.
230
136
  * @throws {TypeError} if `obj` param is not an object
@@ -237,7 +143,7 @@ type deleteXObjElementParams = Parameters<typeof deleteXObjElementEx>;
237
143
  * @throws {TypeError} if `obj` param is not an object
238
144
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
239
145
  */
240
- export function deleteXObjElementEx(obj: INode, name: string): INodeModifResult;
146
+ export function deleteXObjElementEx(obj: INode, name: string): IDeleteNodeResult;
241
147
  /**
242
148
  * Renames an element addressed by its key.
243
149
  * @throws {TypeError} if `obj` param is not an object
@@ -245,21 +151,12 @@ export function deleteXObjElementEx(obj: INode, name: string): INodeModifResult;
245
151
  * @throws {EvalKeyNameError} if `value` param is not valid identifier
246
152
  */
247
153
  export function renameXObjElement(obj: INode, name?: string, value?: string): boolean;
248
- /**
249
- * Clears a given node
250
- * @throws {TypeError} if `node`-param is not an object or array
251
- */
252
- export function clearXObjNode(node: INode | INode[]): boolean;
253
- /**
254
- * Tries to convert a value into an ID.
255
- */
256
- export function evalXObjEName(value: any): null | number | string;
257
154
  /**
258
155
  * Inserts a list elements into a given object.
259
156
  * @throws {TypeError} if `obj` param is not an object
260
157
  * @see insertXObjEListEx
261
158
  */
262
- export function insertXObjEList(...args: insertXObjEListParams): object | object[] | null;
159
+ export function insertXObjEList(...args: insertXObjEListParams): INode[] | null;
263
160
  type insertXObjEListParams = Parameters<typeof insertXObjEListEx>;
264
161
  /**
265
162
  * Inserts a list elements into a given object.
@@ -267,18 +164,22 @@ type insertXObjEListParams = Parameters<typeof insertXObjEListEx>;
267
164
  * @throws {TypeError} if `obj` param is not an object
268
165
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
269
166
  */
270
- export function insertXObjEListEx(obj: INode, name: string, opt?: OPT_inselops_S): INodeModifResult;
167
+ export function insertXObjEListEx(obj: INode, name: string, opt?: OPT_inselops_S): INodeModifResultOnFail | INodeModifResultOnSuccess_S2;
271
168
  /**
272
- * Tries to convert a value into an element name description.
169
+ * Inserts a chain of an elements into a given object.
170
+ * @throws {TypeError} if `obj` param is not an object
171
+ * @experimental
273
172
  */
274
- export function genXObjENameDescr(value: any): XObjENameDescr;
173
+ export function insertXObjEChain(obj: INode, ...args: insertListOfElementsParams): any | null;
275
174
  /**
276
- * Inserts an elements into a given object.
277
- * @throws {TypeError} if `obj` param is not an object
175
+ * Clears a given node
176
+ * @throws {TypeError} if `node`-param is not an object or array
278
177
  */
279
- export function insertXObjElements(obj: object, ...args: any[]): number;
178
+ export function clearXObjNode(node: INode | INode[]): boolean;
280
179
  /**
281
- * Inserts a chain of an elements into a given object.
180
+ * Inserts an elements into a given object.
282
181
  * @throws {TypeError} if `obj` param is not an object
182
+ * @experimental
283
183
  */
284
- export function insertXObjEChain(obj: object, ...args: any[]): any | null;
184
+ export function insertXObjElements(obj: INode, ...args: insertListOfElementsParams): number;
185
+ type insertListOfElementsParams = [ ...names: string[], options: OPT_inselops_L];