@ygracs/xobj-lib-js 0.3.2 → 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/lib/xObj-lib.js CHANGED
@@ -1,256 +1,34 @@
1
- // [v0.3.138-20260530]
1
+ // [v0.3.144-20260704]
2
2
 
3
3
  // === module init block ===
4
4
 
5
5
  const {
6
- valueToIndex,
7
- readAsString, readAsBoolEx, readAsNumberEx,
8
6
  isNullOrUndef,
9
- isInteger,
10
7
  isArray, isObject, isPlainObject,
11
- // * import types definitions *
12
- IValueToStringTransformOptions,
13
8
  } = require('@ygracs/bsfoc-lib-js');
14
9
 
10
+ const {
11
+ evalKeyName,
12
+ } = require('./xObj-names');
13
+
15
14
  const {
16
15
  EvalKeyNameError,
17
16
  XOBJ_ECODE_TABLE,
18
17
  } = require('./xObj-errors');
19
18
 
20
- const {
21
- XOBJ_DEF_TNAMES,
22
- } = require('./xObj-defs');
23
-
24
19
  // === module inner block ===
25
20
 
26
21
  const {
27
- XOBJ_TE_NSTR_EMSG,
28
22
  XOBJ_TE_NSTR_ECODE,
29
23
  XOBJ_TE_NPOBJ_EMSG,
30
24
  XOBJ_TE_NPOBJ_ECODE,
31
- XOBJ_TE_KNES_EMSG,
32
25
  XOBJ_TE_KNES_ECODE,
33
26
  } = XOBJ_ECODE_TABLE;
34
27
 
35
- const {
36
- XOBJ_DEF_PARAM_TNAME,
37
- } = XOBJ_DEF_TNAMES;
38
-
39
- /**
40
- * A result of a value check ops.
41
- * @typedef {Object} RVAL_reason
42
- * @property {string} code - message ID
43
- * @property {string} msg - message text
44
- * @deprecated
45
- * @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameReasonOnFail` instead.
46
- */
47
-
48
- /**
49
- * An error description of a value check ops on fail.
50
- * @since 0.3.0
51
- * @typedef {Object} IEvalKeyNameReasonOnFail
52
- * @property {string} code - message ID
53
- * @property {string} msg - message text
54
- */
55
-
56
- /**
57
- * A result of a value check ops.
58
- * @typedef {Object} VCOR_evalkname
59
- * @property {boolean} isSucceed - ops flag
60
- * @property {string|IEvalKeyNameReasonOnFail} value - result value or reson if failed
61
- * @deprecated
62
- * @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameResult` instead.
63
- */
64
-
65
- /**
66
- * An options setting for `evalKeyName` function
67
- * @since 0.3.0
68
- * @typedef {Object} IEvalKeyNameOptions
69
- * @property {boolean} [onlyNES] - a flag to accept only a non-empty string values
70
- */
71
-
72
- /**
73
- * A result of `evalKeyName` function if succeed
74
- * @since 0.3.0
75
- * @typedef {Object} IEvalKeyNameResultOnSuccess
76
- * @property {true} isSucceed - ops flag
77
- * @property {string} value - result value
78
- */
79
-
80
- /**
81
- * A result of `evalKeyName` function if failed
82
- * @since 0.3.0
83
- * @typedef {Object} IEvalKeyNameResultOnFail
84
- * @property {false} isSucceed - ops flag
85
- * @property {IEvalKeyNameReasonOnFail} value - reason of fail
86
- */
87
-
88
- /**
89
- * A result of `evalKeyName` function
90
- * @since 0.3.0
91
- * @typedef {IEvalKeyNameResultOnSuccess|IEvalKeyNameResultOnFail} IEvalKeyNameResult
92
- */
93
- /**
94
- * A virtual constant meant for support jsdoc notation:
95
- * @type {IEvalKeyNameResult}
96
- */
97
- module.exports.IEvalKeyNameResult = { isSucceed: true, value: '' };
98
-
99
- /**
100
- * Tries to convert a value into an ID.
101
- * @function evalKeyName
102
- * @param {any} value - key to validate
103
- * @param {boolean|IEvalKeyNameOptions} [opt=true] - some options
104
- * @returns {IEvalKeyNameResult}
105
- * @inner
106
- */
107
- function evalKeyName(value, opt = true) {
108
- let {
109
- onlyNES,
110
- } = isPlainObject(opt) ? opt : { onlyNES: opt };
111
- if (typeof value !== 'string') {
112
- return {
113
- isSucceed: false,
114
- value: {
115
- code: XOBJ_TE_NSTR_ECODE,
116
- msg: XOBJ_TE_NSTR_EMSG,
117
- },
118
- };
119
- };
120
- const key = value.trim();
121
- if (onlyNES && key === '') {
122
- return {
123
- isSucceed: false,
124
- value: {
125
- code: XOBJ_TE_KNES_ECODE,
126
- msg: XOBJ_TE_KNES_EMSG,
127
- },
128
- };
129
- };
130
- return {
131
- isSucceed: true,
132
- value: key,
133
- };
134
- };
135
- module.exports.evalKeyName = evalKeyName;
136
-
137
28
  // === module main block ===
138
29
 
139
30
  /**
140
- * Tries to convert a value into an ID.
141
- * @function evalXObjEName
142
- * @param {any} value - some value to evaluate
143
- * @returns {null|number|string}
144
- */
145
- function evalXObjEName(value) {
146
- //return valueToIDString(value); // // TODO: [?]
147
- let name = value;
148
- switch (typeof name) {
149
- case 'number' : {
150
- if (valueToIndex(name) === -1) name = null;
151
- break;
152
- }
153
- case 'string' : {
154
- name = name.trim();
155
- if (name !== '') {
156
- let value = Number(name);
157
- if (!Number.isNaN(value)) {
158
- name = (
159
- value < 0 || !isInteger(value)
160
- ? null
161
- : value
162
- );
163
- };
164
- } else {
165
- name = null;
166
- };
167
- break;
168
- }
169
- default: {
170
- name = null;
171
- }
172
- };
173
- return name;
174
- };
175
-
176
- /**
177
- * Some conditions applied to an element as a result of an element name pattern
178
- * evaluation ops.
179
- * @since 0.3.0
180
- * @typedef {Object} XObjENameDescrConditions
181
- * @property {any} name - element name
182
- * @property {any} type - element type
183
- * @property {any} [value] - some value
184
- */
185
-
186
- /**
187
- * A result of an element name pattern evaluation ops.
188
- * @typedef {Object} XObjENameDescr
189
- * @property {boolean} isERR - ops flag
190
- * @property {null|number|string} name - element name
191
- * @property {?XObjENameDescrConditions} conditions - some conditions applied to an element
192
- */
193
-
194
- /**
195
- * Tries to convert a value into an element name description.
196
- * @function genXObjENameDescr
197
- * @param {any} value - element name pattern
198
- * @returns {XObjENameDescr}
199
- * @experimental
200
- */
201
- function genXObjENameDescr(value) {
202
- let result = null;
203
- let name = null;
204
- let conditions = null;
205
- let isERR = false;
206
- let tail = null;
207
- if (typeof value === 'string') {
208
- const re = /^\s*([^\[\]\s]+)?(\s*)(\[.*])?\s*$/;
209
- tail = value.match(re);
210
- //console.log('CHECK: '+JSON.stringify(tail, null, 2));
211
- if (tail) {
212
- if (tail[1]) {
213
- name = tail[1];
214
- if (name) {
215
- if (tail[2] === '') {
216
- if (tail[3]) {
217
- const re = /\[(@{0,1})(?:([^\[=]*?)(?:(?=[=])(=)((?![\"\'])[^\]]*|(?=([\"\']))\5(.*)\5))?)](\s*.*)/;
218
- tail = tail[3].match(re);
219
- //console.log('CHECK: '+JSON.stringify(tail, null, 2));
220
- if (tail) {
221
- let name = evalXObjEName(tail[2]);
222
- let type = tail[1] === '@' ? 'attribute' : 'child';
223
- let value = undefined;
224
- if (tail[3] === '=') value = tail[5] ? tail[6] : tail[4];
225
- if (tail[7]) isERR = true;
226
- conditions = {
227
- name,
228
- type,
229
- value,
230
- };
231
- };
232
- };
233
- } else if (tail[3]) {
234
- name = null;
235
- };
236
- };
237
- };
238
- };
239
- } else {
240
- name = value;
241
- };
242
- name = evalXObjEName(name);
243
- if (name === null) isERR = true;
244
- result = {
245
- name,
246
- conditions,
247
- isERR,
248
- };
249
- return result;
250
- };
251
-
252
- /**
253
- *
31
+ * A `Node`-element
254
32
  * @since 0.3.2
255
33
  * @typedef {Object<string, any>} INode
256
34
  */
@@ -260,7 +38,7 @@ function genXObjENameDescr(value) {
260
38
  */
261
39
  module.exports.INode = {};
262
40
  /**
263
- * A list of a `INode`-elements
41
+ * A list of a `Node`-elements
264
42
  * @since 0.3.2
265
43
  * @typedef {INode[]} INodeList
266
44
  */
@@ -268,7 +46,7 @@ module.exports.INode = {};
268
46
  /**
269
47
  * Extracts an element from a given object by its key.
270
48
  * @function getXObjElement
271
- * @param {object} obj - some object
49
+ * @param {INode} obj - some object
272
50
  * @param {string} name - some child element
273
51
  * @returns {?any}
274
52
  * @throws {TypeError} if `obj` param is not an object
@@ -291,15 +69,6 @@ function getXObjElement(obj, name) {
291
69
  };
292
70
  module.exports.getXObjElement = getXObjElement;
293
71
 
294
- /**
295
- * A result of an xObj modification ops
296
- * @typedef {Object} RVAL_emodif
297
- * @property {boolean} isSucceed - flag that indicates whether an ops is succeed or not
298
- * @property {?(object|object[])} item - some element as a result
299
- * @deprecated
300
- * @todo \[from v0.3.2] make obsolete. Use `INodeModifResult` instead.
301
- */
302
-
303
72
  /**
304
73
  * A result of an xObj modification ops if failed
305
74
  * @since 0.3.2
@@ -307,33 +76,18 @@ module.exports.getXObjElement = getXObjElement;
307
76
  * @property {false} isSucceed - flag that indicates whether an ops is succeed or not
308
77
  * @property {null} item - some element as a result
309
78
  */
310
-
311
- /**
312
- * A result of an xObj modification ops if succeed
313
- * @since 0.3.2
314
- * @typedef {Object} INodeModifResultOnSuccess
315
- * @property {true} isSucceed - flag that indicates whether an ops is succeed or not
316
- * @property {object|object[]} item - some element as a result
317
- */
318
-
319
- /**
320
- * A result of an xObj modification ops
321
- * @since 0.3.2
322
- * @typedef {INodeModifResultOnFail|INodeModifResultOnSuccess} INodeModifResult
323
- */
324
-
325
79
  /**
326
80
  * A virtual constant meant for support jsdoc notation:
327
- * @type {INodeModifResult}
81
+ * @type {INodeModifResultOnFail}
328
82
  */
329
- module.exports.INodeModifResult = { isSucceed: false, item: null };
83
+ module.exports.INodeModifResultOnFail = { isSucceed: false, item: null };
330
84
 
331
85
  /**
332
- *
86
+ * Function interface for adding some child element to `INode`
333
87
  * @callback addXObjElementFn
334
- * @param {object} obj - some object
88
+ * @param {INode} obj - some object
335
89
  * @param {string} name - some child element
336
- * @returns {?object}
90
+ * @returns {?INode}
337
91
  * @see {@link addXObjElementEx} for param details
338
92
  */
339
93
  /**
@@ -360,13 +114,32 @@ function addXObjElement(...args) {
360
114
  };
361
115
  module.exports.addXObjElement = addXObjElement;
362
116
 
117
+ /**
118
+ * A result of an xObj modification ops if succeed (when child element returned)
119
+ * @since 0.4.0
120
+ * @typedef {Object} INodeModifResultOnSuccess_S1
121
+ * @property {true} isSucceed - flag that indicates whether an ops is succeed or not
122
+ * @property {INode} item - some element as a result
123
+ */
124
+ /**
125
+ * A virtual constant meant for support jsdoc notation:
126
+ * @type {INodeModifResultOnSuccess_S1}
127
+ */
128
+ module.exports.INodeModifResultOnSuccess_S1 = { isSucceed: true, item: {} };
129
+
130
+ /**
131
+ * A result of an xObj modification ops
132
+ * @since 0.4.0
133
+ * @typedef {INodeModifResultOnFail|INodeModifResultOnSuccess_S1} IAddNodeResult
134
+ */
135
+
363
136
  /**
364
137
  * Adds an element addressed by its key to a given object.
365
138
  * @since 0.3.0
366
139
  * @function addXObjElementEx
367
- * @param {object} obj - some object
140
+ * @param {INode} obj - some object
368
141
  * @param {string} name - some child element
369
- * @returns {INodeModifResult}
142
+ * @returns {IAddNodeResult}
370
143
  * @throws {TypeError} if `obj` param is not an object
371
144
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
372
145
  */
@@ -416,12 +189,12 @@ module.exports.addXObjElementEx = addXObjElementEx;
416
189
  */
417
190
 
418
191
  /**
419
- *
192
+ * Function interface for inserting some child element into `INode`
420
193
  * @callback insertXObjElementFn
421
- * @param {object} obj - some object
194
+ * @param {INode} obj - some object
422
195
  * @param {string} name - some child element
423
196
  * @param {OPT_inselops_L} [opt] - options
424
- * @returns {?object}
197
+ * @returns {?INode|INode[]}
425
198
  * @see {@link insertXObjElementEx} for param details
426
199
  */
427
200
  /**
@@ -448,14 +221,33 @@ function insertXObjElement(...args) {
448
221
  };
449
222
  module.exports.insertXObjElement = insertXObjElement;
450
223
 
224
+ /**
225
+ * A result of an xObj modification ops if succeed (when child element returned)
226
+ * @since 0.4.0
227
+ * @typedef {Object} INodeModifResultOnSuccess_S2
228
+ * @property {true} isSucceed - flag that indicates whether an ops is succeed or not
229
+ * @property {INode[]} item - some element as a result
230
+ */
231
+ /**
232
+ * A virtual constant meant for support jsdoc notation:
233
+ * @type {INodeModifResultOnSuccess_S2}
234
+ */
235
+ module.exports.INodeModifResultOnSuccess_S2 = { isSucceed: true, item: [] };
236
+
237
+ /**
238
+ * A result of an xObj modification ops
239
+ * @since 0.4.0
240
+ * @typedef {INodeModifResultOnFail|INodeModifResultOnSuccess_S1|INodeModifResultOnSuccess_S2} IInsertNodeResult
241
+ */
242
+
451
243
  /**
452
244
  * Inserts an element addressed by its key into a given object.
453
245
  * @since 0.2.0
454
246
  * @function insertXObjElementEx
455
- * @param {object} obj - some object
247
+ * @param {INode} obj - some object
456
248
  * @param {string} name - some child element
457
249
  * @param {OPT_inselops_L} [opt] - options
458
- * @returns {INodeModifResult}
250
+ * @returns {IInsertNodeResult}
459
251
  * @throws {TypeError} if `obj` param is not an object
460
252
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
461
253
  */
@@ -504,9 +296,9 @@ function insertXObjElementEx(obj, name, opt) {
504
296
  module.exports.insertXObjElementEx = insertXObjElementEx;
505
297
 
506
298
  /**
507
- *
299
+ * Function interface for deleting some child element from `INode`
508
300
  * @callback deleteXObjElementFn
509
- * @param {object} obj - some object
301
+ * @param {INode} obj - some object
510
302
  * @param {string} name - some child element
511
303
  * @returns {boolean}
512
304
  * @see {@link deleteXObjElementEx} for param details
@@ -535,12 +327,31 @@ function deleteXObjElement(...args) {
535
327
  };
536
328
  module.exports.deleteXObjElement = deleteXObjElement;
537
329
 
330
+ /**
331
+ * A result of an xObj modification ops if succeed (when child element not returned)
332
+ * @since 0.4.0
333
+ * @typedef {Object} INodeModifResultOnSuccess_S0
334
+ * @property {true} isSucceed - flag that indicates whether an ops is succeed or not
335
+ * @property {null} item - some element as a result
336
+ */
337
+ /**
338
+ * A virtual constant meant for support jsdoc notation:
339
+ * @type {INodeModifResultOnSuccess_S0}
340
+ */
341
+ module.exports.INodeModifResultOnSuccess_S0 = { isSucceed: true, item: null };
342
+
343
+ /**
344
+ * A result of an xObj modification ops
345
+ * @since 0.4.0
346
+ * @typedef {INodeModifResultOnFail|INodeModifResultOnSuccess_S0|INodeModifResultOnSuccess_S1|INodeModifResultOnSuccess_S2} IDeleteNodeResult
347
+ */
348
+
538
349
  /**
539
350
  * Deletes an element addressed by its key from a given object.
540
351
  * @function deleteXObjElementEx
541
- * @param {object} obj - some object
352
+ * @param {INode} obj - some object
542
353
  * @param {string} name - some child element
543
- * @returns {INodeModifResult}
354
+ * @returns {IDeleteNodeResult}
544
355
  * @throws {TypeError} if `obj` param is not an object
545
356
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
546
357
  */
@@ -557,9 +368,16 @@ function deleteXObjElementEx(obj, name) {
557
368
  let isSucceed = false;
558
369
  // // TODO: catch errors in strict mode
559
370
  isSucceed = delete obj[key];
560
- return {
561
- isSucceed,
562
- item: isSucceed && isObject(prop) ? prop : null,
371
+ if (isSucceed) {
372
+ return {
373
+ isSucceed,
374
+ item: isObject(prop) ? prop : null,
375
+ };
376
+ } else {
377
+ return {
378
+ isSucceed,
379
+ item: null,
380
+ };
563
381
  };
564
382
  } else {
565
383
  const { code, msg } = key;
@@ -571,7 +389,7 @@ module.exports.deleteXObjElementEx = deleteXObjElementEx;
571
389
  /**
572
390
  * Renames an element addressed by its key.
573
391
  * @function renameXObjElement
574
- * @param {object} obj - some object
392
+ * @param {INode} obj - some object
575
393
  * @param {string} name - some child element
576
394
  * @param {string} value - new element ID
577
395
  * @returns {boolean}
@@ -617,7 +435,7 @@ module.exports.renameXObjElement = renameXObjElement;
617
435
  /**
618
436
  * Inserts an elements into a given object.
619
437
  * @function insertXObjElements
620
- * @param {object} obj - some object
438
+ * @param {INode} obj - some object
621
439
  * @param {...string} name - some child element name
622
440
  * @param {OPT_inselops_L} [opt]
623
441
  * @returns {number}
@@ -652,15 +470,21 @@ function insertXObjElements(obj, ...args) {
652
470
  */
653
471
 
654
472
  /**
655
- * Inserts a list elements into a given object.
656
- * @function insertXObjEList
657
- * @param {object} obj - some object
473
+ *
474
+ * @callback insertXObjEListFn
475
+ * @param {INode} obj - some object
658
476
  * @param {string} name - some child element name
659
477
  * @param {OPT_inselops_S} [opt] - options
660
- * @returns {?(object|object[])}
478
+ * @returns {?INode[]}
479
+ * @see {@link insertXObjEListEx} for param details
480
+ */
481
+ /**
482
+ * Inserts a list elements into a given object.
483
+ * @type {insertXObjEListFn}
661
484
  * @throws {TypeError} if `obj` param is not an object
662
485
  */
663
486
  function insertXObjEList(...args) {
487
+ /** @type {?INode[]} */
664
488
  let item = null;
665
489
  try {
666
490
  ({ item } = insertXObjEListEx(...args));
@@ -677,15 +501,16 @@ function insertXObjEList(...args) {
677
501
  };
678
502
  return item;
679
503
  };
504
+ module.exports.insertXObjEList = insertXObjEList;
680
505
 
681
506
  /**
682
507
  * Inserts a list elements into a given object.
683
508
  * @since 0.2.0
684
509
  * @function insertXObjEListEx
685
- * @param {object} obj - some object
510
+ * @param {INode} obj - some object
686
511
  * @param {string} name - some child element name
687
512
  * @param {OPT_inselops_S} [opt] - options
688
- * @returns {INodeModifResult}
513
+ * @returns {INodeModifResultOnFail|INodeModifResultOnSuccess_S2}
689
514
  * @throws {TypeError} if `obj` param is not an object
690
515
  * @throws {EvalKeyNameError} if `name` param is not valid identifier
691
516
  */
@@ -729,13 +554,14 @@ function insertXObjEListEx(obj, name, opt) {
729
554
  throw new EvalKeyNameError(msg, { code });
730
555
  };
731
556
  };
557
+ module.exports.insertXObjEListEx = insertXObjEListEx;
732
558
 
733
559
  /**
734
560
  * Inserts a chain of an elements into a given object.
735
561
  * @function insertXObjEChain
736
- * @param {object} obj - some object
562
+ * @param {INode} obj - some object
737
563
  * @param {...string} name - some child element name
738
- * @param {object} [opt] - options
564
+ * @param {OPT_inselops_L} [opt] - options
739
565
  * @returns {?any}
740
566
  * @throws {TypeError} if `obj` param is not an object
741
567
  * @experimental
@@ -760,18 +586,23 @@ function insertXObjEChain(obj, ...args) {
760
586
  let isSucceed = false;
761
587
  for (let key of args) {
762
588
  child = insertXObjElement(parent, key, opt);
763
- isSucceed = isPlainObject(child);
764
- if (!isSucceed) break;
765
- parent = child;
589
+ if (isPlainObject(child)) {
590
+ parent = child;
591
+ isSucceed = true;
592
+ } else {
593
+ isSucceed = false;
594
+ break;
595
+ };
766
596
  };
767
597
  result = isSucceed ? parent : null;
768
598
  };
769
599
  return result;
770
600
  };
601
+ module.exports.insertXObjEChain = insertXObjEChain;
771
602
 
772
603
  /**
773
604
  * Clears a given node
774
- * @param {object|object[]} node - some node
605
+ * @param {INode|INode[]} node - some node
775
606
  * @returns {boolean}
776
607
  * @throws {TypeError} if `node`-param is not an object or array
777
608
  */
@@ -798,11 +629,5 @@ module.exports.clearXObjNode = clearXObjNode;
798
629
 
799
630
  // === module exports block ===
800
631
 
801
- module.exports.evalXObjEName = evalXObjEName;
802
- module.exports.insertXObjEList = insertXObjEList;
803
- module.exports.insertXObjEListEx = insertXObjEListEx;
804
-
805
632
  // * experimental *
806
- module.exports.genXObjENameDescr = genXObjENameDescr;
807
633
  module.exports.insertXObjElements = insertXObjElements;
808
- module.exports.insertXObjEChain = insertXObjEChain;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * A result of `evalKeyName` function
3
+ */
4
+ export type IEvalKeyNameResult = IEvalKeyNameResultOnSuccess | IEvalKeyNameResultOnFail;
5
+ export const IEvalKeyNameResult: IEvalKeyNameResult;
6
+ /**
7
+ * Some conditions applied to an element as a result of an element name pattern
8
+ * evaluation ops.
9
+ */
10
+ export type IXObjENameDescrConditions = {
11
+ /**
12
+ * - element name
13
+ */
14
+ name: any;
15
+ /**
16
+ * - element type
17
+ */
18
+ type: any;
19
+ /**
20
+ * - some value
21
+ */
22
+ value?: any;
23
+ };
24
+ /**
25
+ * A result of an element name pattern evaluation ops.
26
+ */
27
+ export type IXObjENameDescr = {
28
+ /**
29
+ * - ops flag
30
+ */
31
+ isERR: boolean;
32
+ /**
33
+ * - element name
34
+ */
35
+ name: null | number | string;
36
+ /**
37
+ * - some conditions applied to an element
38
+ */
39
+ conditions: IXObjENameDescrConditions | null;
40
+ };
41
+ /**
42
+ * An error description of a value check ops on fail.
43
+ */
44
+ export type IEvalKeyNameReasonOnFail = {
45
+ /**
46
+ * - message ID
47
+ */
48
+ code: string;
49
+ /**
50
+ * - message text
51
+ */
52
+ msg: string;
53
+ };
54
+ /**
55
+ * An options setting for `evalKeyName` function
56
+ */
57
+ export type IEvalKeyNameOptions = {
58
+ /**
59
+ * - a flag to accept only a non-empty string values
60
+ */
61
+ onlyNES?: boolean;
62
+ };
63
+ /**
64
+ * A result of `evalKeyName` function if succeed
65
+ */
66
+ export type IEvalKeyNameResultOnSuccess = {
67
+ /**
68
+ * - ops flag
69
+ */
70
+ isSucceed: true;
71
+ /**
72
+ * - result value
73
+ */
74
+ value: string;
75
+ };
76
+ /**
77
+ * A result of `evalKeyName` function if failed
78
+ */
79
+ export type IEvalKeyNameResultOnFail = {
80
+ /**
81
+ * - ops flag
82
+ */
83
+ isSucceed: false;
84
+ /**
85
+ * - reason of fail
86
+ */
87
+ value: IEvalKeyNameReasonOnFail;
88
+ };
89
+
90
+ /**
91
+ * Tries to convert a value into an ID.
92
+ * @inner
93
+ */
94
+ export function evalKeyName(value: any, opt?: boolean | IEvalKeyNameOptions): IEvalKeyNameResult;
95
+ /**
96
+ * Tries to convert a value into an ID.
97
+ */
98
+ export function evalXObjEName(value: any): null | number | string;
99
+ /**
100
+ * Tries to convert a value into an element name description.
101
+ */
102
+ export function genXObjENameDescr(value: any): IXObjENameDescr;