@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/CHANGELOG.md +14 -0
- package/doc/xObj.md +44 -38
- package/index.d.ts +13 -15
- package/index.js +11 -3
- package/lib/xObj-attr.d.ts +29 -17
- package/lib/xObj-attr.js +46 -20
- package/lib/xObj-lib.d.ts +69 -168
- package/lib/xObj-lib.js +118 -293
- package/lib/xObj-names.d.ts +102 -0
- package/lib/xObj-names.js +219 -0
- package/lib/xObj-param.d.ts +35 -21
- package/lib/xObj-param.js +44 -16
- package/package.json +3 -2
package/lib/xObj-attr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.3.
|
|
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,
|
|
@@ -44,7 +47,7 @@ const {
|
|
|
44
47
|
/**
|
|
45
48
|
* Extracts an attributes from a given object by its key.
|
|
46
49
|
* @function getXObjAttributes
|
|
47
|
-
* @param {
|
|
50
|
+
* @param {INode} obj - some object
|
|
48
51
|
* @param {string} [key=XOBJ_DEF_ATTR_TNAME] - some key
|
|
49
52
|
* @returns {?INode}
|
|
50
53
|
* @throws {TypeError} if `obj` param is not an object
|
|
@@ -71,7 +74,7 @@ module.exports.getXObjAttributes = getXObjAttributes;
|
|
|
71
74
|
/**
|
|
72
75
|
* Checks whether an attribute is exists.
|
|
73
76
|
* @function checkXObjAttribute
|
|
74
|
-
* @param {
|
|
77
|
+
* @param {INode} obj - some object
|
|
75
78
|
* @param {string} attr - some attribute ID
|
|
76
79
|
* @param {string} [key] - some key
|
|
77
80
|
* @returns {boolean}
|
|
@@ -101,7 +104,7 @@ module.exports.checkXObjAttribute = checkXObjAttribute;
|
|
|
101
104
|
/**
|
|
102
105
|
* Deletes an attribute addressed by a given name.
|
|
103
106
|
* @function deleteXObjAttribute
|
|
104
|
-
* @param {
|
|
107
|
+
* @param {INode} obj - some object
|
|
105
108
|
* @param {string} attr - some attribute ID
|
|
106
109
|
* @param {string} [key] - some key
|
|
107
110
|
* @returns {boolean}
|
|
@@ -136,7 +139,7 @@ module.exports.deleteXObjAttribute = deleteXObjAttribute;
|
|
|
136
139
|
* Renames an attribute addressed by a given name.
|
|
137
140
|
* @since 0.2.0
|
|
138
141
|
* @function renameXObjAttribute
|
|
139
|
-
* @param {
|
|
142
|
+
* @param {INode} obj - some object
|
|
140
143
|
* @param {string} attr - some attribute ID
|
|
141
144
|
* @param {string} value - new attribute ID
|
|
142
145
|
* @param {string} [key] - some key
|
|
@@ -192,7 +195,7 @@ module.exports.renameXObjAttribute = renameXObjAttribute;
|
|
|
192
195
|
/**
|
|
193
196
|
* Extracts an attribute 'AS IS' from a given object.
|
|
194
197
|
* @function readXObjAttrRaw
|
|
195
|
-
* @param {
|
|
198
|
+
* @param {INode} obj - some object
|
|
196
199
|
* @param {string} attr - some attribute
|
|
197
200
|
* @param {string} [key] - some key
|
|
198
201
|
* @returns {any}
|
|
@@ -222,7 +225,7 @@ module.exports.readXObjAttrRaw = readXObjAttrRaw;
|
|
|
222
225
|
/**
|
|
223
226
|
* Writes a parameter into a given object.
|
|
224
227
|
* @function writeXObjAttrRaw
|
|
225
|
-
* @param {
|
|
228
|
+
* @param {INode} obj - some object
|
|
226
229
|
* @param {string} attr - some attribute
|
|
227
230
|
* @param {any} value - some value
|
|
228
231
|
* @param {string} [key=XOBJ_DEF_ATTR_TNAME] - some key
|
|
@@ -272,7 +275,7 @@ module.exports.writeXObjAttrRaw = writeXObjAttrRaw;
|
|
|
272
275
|
/**
|
|
273
276
|
* Extracts an attribute from a given object and returns it as a string.
|
|
274
277
|
* @function readXObjAttr
|
|
275
|
-
* @param {
|
|
278
|
+
* @param {INode} obj - some object
|
|
276
279
|
* @param {string} attr - some attribute
|
|
277
280
|
* @param {string} [key] - some key
|
|
278
281
|
* @returns {string}
|
|
@@ -298,7 +301,7 @@ module.exports.readXObjAttr = readXObjAttr;
|
|
|
298
301
|
/**
|
|
299
302
|
* Extracts an attribute from a given object and returns it as a boolean.
|
|
300
303
|
* @function readXObjAttrAsBool
|
|
301
|
-
* @param {
|
|
304
|
+
* @param {INode} obj - some object
|
|
302
305
|
* @param {string} attr - some attribute
|
|
303
306
|
* @param {boolean} [defValue] - default value
|
|
304
307
|
* @param {string} [key] - some key
|
|
@@ -327,7 +330,7 @@ module.exports.readXObjAttrAsBool = readXObjAttrAsBool;
|
|
|
327
330
|
/**
|
|
328
331
|
* Extracts an attribute from a given object and returns it as a number.
|
|
329
332
|
* @function readXObjAttrAsNum
|
|
330
|
-
* @param {
|
|
333
|
+
* @param {INode} obj - some object
|
|
331
334
|
* @param {string} attr - some attribute
|
|
332
335
|
* @param {number} [defValue] - default value
|
|
333
336
|
* @param {string} [key] - some key
|
|
@@ -356,7 +359,7 @@ module.exports.readXObjAttrAsNum = readXObjAttrAsNum;
|
|
|
356
359
|
/**
|
|
357
360
|
* Extracts an attribute from a given object and returns it as 'index' value.
|
|
358
361
|
* @function readXObjAttrAsIndex
|
|
359
|
-
* @param {
|
|
362
|
+
* @param {INode} obj - some object
|
|
360
363
|
* @param {string} attr - some attribute
|
|
361
364
|
* @param {string} [key] - some key
|
|
362
365
|
* @returns {number}
|
|
@@ -380,12 +383,24 @@ function readXObjAttrAsIndex(obj, attr, key) {
|
|
|
380
383
|
};
|
|
381
384
|
module.exports.readXObjAttrAsIndex = readXObjAttrAsIndex;
|
|
382
385
|
|
|
386
|
+
/**
|
|
387
|
+
*
|
|
388
|
+
* @typedef {string} readXObjAttrOptionAsStr
|
|
389
|
+
* @deprecated
|
|
390
|
+
* @todo \[since `v0.2.1`] deprecated and will be removed
|
|
391
|
+
*/
|
|
392
|
+
/**
|
|
393
|
+
* A virtual constant meant for support jsdoc notation:
|
|
394
|
+
* @type {readXObjAttrOptionAsStr}
|
|
395
|
+
*/
|
|
396
|
+
module.exports.readXObjAttrOptionAsStr = '';
|
|
397
|
+
|
|
383
398
|
/**
|
|
384
399
|
* Extracts an attribute from a given object and returns it as a string.
|
|
385
400
|
* @function readXObjAttrEx
|
|
386
|
-
* @param {
|
|
401
|
+
* @param {INode} obj - some object
|
|
387
402
|
* @param {string} attr - some attribute
|
|
388
|
-
* @param {
|
|
403
|
+
* @param {readXObjAttrOptionAsStr|IValueToStringTransformOptions} [opt] - options
|
|
389
404
|
* @param {string} [key] - some key
|
|
390
405
|
* @returns {string}
|
|
391
406
|
* @throws {TypeError} if `obj` param is not an object
|
|
@@ -405,7 +420,6 @@ function readXObjAttrEx(obj, attr, opt, key) {
|
|
|
405
420
|
}
|
|
406
421
|
};
|
|
407
422
|
};
|
|
408
|
-
/** @type {IValueToStringTransformOptions} */
|
|
409
423
|
const _opt = isPlainObject(opt) ? opt : {
|
|
410
424
|
useTrim: true,
|
|
411
425
|
numberToString: true,
|
|
@@ -420,7 +434,7 @@ module.exports.readXObjAttrEx = readXObjAttrEx;
|
|
|
420
434
|
* Tries to convert a given value to a string and writes it as an attribute
|
|
421
435
|
* into a given object.
|
|
422
436
|
* @function writeXObjAttr
|
|
423
|
-
* @param {
|
|
437
|
+
* @param {INode} obj - some object
|
|
424
438
|
* @param {string} attr - some attribute
|
|
425
439
|
* @param {any} value - some value
|
|
426
440
|
* @param {string} [key] - some key
|
|
@@ -448,7 +462,7 @@ module.exports.writeXObjAttr = writeXObjAttr;
|
|
|
448
462
|
* Tries to convert a given value to a boolean and writes it as an attribute
|
|
449
463
|
* into a given object.
|
|
450
464
|
* @function writeXObjAttrAsBool
|
|
451
|
-
* @param {
|
|
465
|
+
* @param {INode} obj - some object
|
|
452
466
|
* @param {string} attr - some attribute
|
|
453
467
|
* @param {any} value - some value
|
|
454
468
|
* @param {boolean} [defValue] - default value
|
|
@@ -481,7 +495,7 @@ module.exports.writeXObjAttrAsBool = writeXObjAttrAsBool;
|
|
|
481
495
|
* Tries to convert a given value to a number and writes it as an attribute
|
|
482
496
|
* into a given object.
|
|
483
497
|
* @function writeXObjAttrAsNum
|
|
484
|
-
* @param {
|
|
498
|
+
* @param {INode} obj - some object
|
|
485
499
|
* @param {string} attr - some attribute
|
|
486
500
|
* @param {any} value - some value
|
|
487
501
|
* @param {number} [defValue] - default value
|
|
@@ -514,7 +528,7 @@ module.exports.writeXObjAttrAsNum = writeXObjAttrAsNum;
|
|
|
514
528
|
* Tries to convert a given value into an 'index' value and writes it
|
|
515
529
|
* as an attribute into a given object.
|
|
516
530
|
* @function writeXObjAttrAsIndex
|
|
517
|
-
* @param {
|
|
531
|
+
* @param {INode} obj - some object
|
|
518
532
|
* @param {string} attr - some attribute
|
|
519
533
|
* @param {any} value - some value
|
|
520
534
|
* @param {string} [key] - some key
|
|
@@ -542,14 +556,26 @@ function writeXObjAttrAsIndex(obj, attr, value, key) {
|
|
|
542
556
|
};
|
|
543
557
|
module.exports.writeXObjAttrAsIndex = writeXObjAttrAsIndex;
|
|
544
558
|
|
|
559
|
+
/**
|
|
560
|
+
*
|
|
561
|
+
* @typedef {string} writeXObjAttrOptionAsStr
|
|
562
|
+
* @deprecated
|
|
563
|
+
* @todo \[since `v0.2.1`] deprecated and will be removed
|
|
564
|
+
*/
|
|
565
|
+
/**
|
|
566
|
+
* A virtual constant meant for support jsdoc notation:
|
|
567
|
+
* @type {writeXObjAttrOptionAsStr}
|
|
568
|
+
*/
|
|
569
|
+
module.exports.writeXObjAttrOptionAsStr = '';
|
|
570
|
+
|
|
545
571
|
/**
|
|
546
572
|
* Tries to convert a given value to a string and writes it as an attribute
|
|
547
573
|
* into a given object.
|
|
548
574
|
* @function writeXObjAttrEx
|
|
549
|
-
* @param {
|
|
575
|
+
* @param {INode} obj - some object
|
|
550
576
|
* @param {string} attr - some attribute
|
|
551
577
|
* @param {any} value - some value
|
|
552
|
-
* @param {
|
|
578
|
+
* @param {writeXObjAttrOptionAsStr|IValueToStringTransformOptions} [opt] - options
|
|
553
579
|
* @param {string} [key] - some key
|
|
554
580
|
* @returns {boolean}
|
|
555
581
|
* @throws {TypeError} if `obj` param is not an object
|
package/lib/xObj-lib.d.ts
CHANGED
|
@@ -1,208 +1,114 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A
|
|
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.
|
|
10
|
+
* A result of an xObj modification ops if failed
|
|
18
11
|
*/
|
|
19
|
-
export type
|
|
20
|
-
/**
|
|
21
|
-
* - element name
|
|
22
|
-
*/
|
|
23
|
-
name: any;
|
|
12
|
+
export type INodeModifResultOnFail = {
|
|
24
13
|
/**
|
|
25
|
-
* -
|
|
14
|
+
* - flag that indicates whether an ops is succeed or not
|
|
26
15
|
*/
|
|
27
|
-
|
|
16
|
+
isSucceed: false;
|
|
28
17
|
/**
|
|
29
|
-
* - some
|
|
18
|
+
* - some element as a result
|
|
30
19
|
*/
|
|
31
|
-
|
|
20
|
+
item: null;
|
|
32
21
|
};
|
|
22
|
+
export const INodeModifResultOnFail: INodeModifResultOnFail;
|
|
33
23
|
/**
|
|
34
|
-
* A result of an
|
|
24
|
+
* A result of an xObj modification ops if succeed (when child element returned)
|
|
35
25
|
*/
|
|
36
|
-
export type
|
|
26
|
+
export type INodeModifResultOnSuccess_S1 = {
|
|
37
27
|
/**
|
|
38
|
-
* - ops
|
|
39
|
-
*/
|
|
40
|
-
isERR: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* - element name
|
|
28
|
+
* - flag that indicates whether an ops is succeed or not
|
|
43
29
|
*/
|
|
44
|
-
|
|
30
|
+
isSucceed: true;
|
|
45
31
|
/**
|
|
46
|
-
* - some
|
|
32
|
+
* - some element as a result
|
|
47
33
|
*/
|
|
48
|
-
|
|
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;
|
|
34
|
+
item: INode;
|
|
68
35
|
};
|
|
36
|
+
export const INodeModifResultOnSuccess_S1: INodeModifResultOnSuccess_S1;
|
|
69
37
|
/**
|
|
70
|
-
* A result of
|
|
71
|
-
* @deprecated
|
|
72
|
-
* @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameReasonOnFail` instead.
|
|
38
|
+
* A result of an xObj modification ops if succeed (when child element returned)
|
|
73
39
|
*/
|
|
74
|
-
export type
|
|
40
|
+
export type INodeModifResultOnSuccess_S2 = {
|
|
75
41
|
/**
|
|
76
|
-
* -
|
|
42
|
+
* - flag that indicates whether an ops is succeed or not
|
|
77
43
|
*/
|
|
78
|
-
|
|
44
|
+
isSucceed: true;
|
|
79
45
|
/**
|
|
80
|
-
* -
|
|
46
|
+
* - some element as a result
|
|
81
47
|
*/
|
|
82
|
-
|
|
48
|
+
item: INode[];
|
|
83
49
|
};
|
|
50
|
+
export const INodeModifResultOnSuccess_S2: INodeModifResultOnSuccess_S2;
|
|
84
51
|
/**
|
|
85
|
-
*
|
|
52
|
+
* A result of an xObj modification ops if succeed (when child element not returned)
|
|
86
53
|
*/
|
|
87
|
-
export type
|
|
54
|
+
export type INodeModifResultOnSuccess_S0 = {
|
|
88
55
|
/**
|
|
89
|
-
* -
|
|
56
|
+
* - flag that indicates whether an ops is succeed or not
|
|
90
57
|
*/
|
|
91
|
-
|
|
58
|
+
isSucceed: true;
|
|
92
59
|
/**
|
|
93
|
-
* -
|
|
60
|
+
* - some element as a result
|
|
94
61
|
*/
|
|
95
|
-
|
|
62
|
+
item: null;
|
|
96
63
|
};
|
|
64
|
+
export const INodeModifResultOnSuccess_S0: INodeModifResultOnSuccess_S0;
|
|
97
65
|
/**
|
|
98
|
-
* A
|
|
99
|
-
* @deprecated
|
|
100
|
-
* @todo \[from v0.3.0] make obsolete. Use `IEvalKeyNameResult` instead.
|
|
66
|
+
* A list of a `Node`-elements
|
|
101
67
|
*/
|
|
102
|
-
export type
|
|
103
|
-
/**
|
|
104
|
-
* - ops flag
|
|
105
|
-
*/
|
|
106
|
-
isSucceed: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* - result value or reson if failed
|
|
109
|
-
*/
|
|
110
|
-
value: string | IEvalKeyNameReasonOnFail;
|
|
111
|
-
};
|
|
68
|
+
export type INodeList = INode[];
|
|
112
69
|
/**
|
|
113
|
-
*
|
|
70
|
+
* A result of an xObj modification ops
|
|
71
|
+
* @since 0.4.0
|
|
114
72
|
*/
|
|
115
|
-
export type
|
|
116
|
-
/**
|
|
117
|
-
* - a flag to accept only a non-empty string values
|
|
118
|
-
*/
|
|
119
|
-
onlyNES?: boolean;
|
|
120
|
-
};
|
|
73
|
+
export type IAddNodeResult = INodeModifResultOnFail | INodeModifResultOnSuccess_S1;
|
|
121
74
|
/**
|
|
122
|
-
*
|
|
123
|
-
*/
|
|
124
|
-
export type IEvalKeyNameResultOnSuccess = {
|
|
125
|
-
/**
|
|
126
|
-
* - ops flag
|
|
127
|
-
*/
|
|
128
|
-
isSucceed: true;
|
|
129
|
-
/**
|
|
130
|
-
* - result value
|
|
131
|
-
*/
|
|
132
|
-
value: string;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* A result of `evalKeyName` function if failed
|
|
75
|
+
* An options for an element insertion ops
|
|
136
76
|
*/
|
|
137
|
-
export type
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
* @
|
|
150
|
-
* @todo \[from v0.3.2] make obsolete. Use `INodeModifResult` instead.
|
|
84
|
+
* @since 0.4.0
|
|
151
85
|
*/
|
|
152
|
-
export type
|
|
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
|
|
88
|
+
* A result of an xObj modification ops
|
|
89
|
+
* @since 0.4.0
|
|
164
90
|
*/
|
|
165
|
-
export type
|
|
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
|
-
*
|
|
93
|
+
* An options for an element insertion ops
|
|
177
94
|
*/
|
|
178
|
-
export type
|
|
179
|
-
|
|
180
|
-
|
|
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
|
|
197
103
|
* @throws {EvalKeyNameError} if `name` param is not valid identifier
|
|
198
104
|
*/
|
|
199
|
-
export function getXObjElement(obj:
|
|
105
|
+
export function getXObjElement(obj: INode, name: string): any | null;
|
|
200
106
|
/**
|
|
201
107
|
* Adds an element addressed by its key to a given object.
|
|
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):
|
|
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:
|
|
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):
|
|
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:
|
|
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,29 +143,20 @@ 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:
|
|
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
|
|
244
150
|
* @throws {EvalKeyNameError} if `name` param is not valid identifier
|
|
245
151
|
* @throws {EvalKeyNameError} if `value` param is not valid identifier
|
|
246
152
|
*/
|
|
247
|
-
export function renameXObjElement(obj:
|
|
248
|
-
/**
|
|
249
|
-
* Clears a given node
|
|
250
|
-
* @throws {TypeError} if `node`-param is not an object or array
|
|
251
|
-
*/
|
|
252
|
-
export function clearXObjNode(node: object | object[]): boolean;
|
|
253
|
-
/**
|
|
254
|
-
* Tries to convert a value into an ID.
|
|
255
|
-
*/
|
|
256
|
-
export function evalXObjEName(value: any): null | number | string;
|
|
153
|
+
export function renameXObjElement(obj: INode, name?: string, value?: string): boolean;
|
|
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):
|
|
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:
|
|
167
|
+
export function insertXObjEListEx(obj: INode, name: string, opt?: OPT_inselops_S): INodeModifResultOnFail | INodeModifResultOnSuccess_S2;
|
|
271
168
|
/**
|
|
272
|
-
*
|
|
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
|
|
173
|
+
export function insertXObjEChain(obj: INode, ...args: insertListOfElementsParams): any | null;
|
|
275
174
|
/**
|
|
276
|
-
*
|
|
277
|
-
* @throws {TypeError} if `
|
|
175
|
+
* Clears a given node
|
|
176
|
+
* @throws {TypeError} if `node`-param is not an object or array
|
|
278
177
|
*/
|
|
279
|
-
export function
|
|
178
|
+
export function clearXObjNode(node: INode | INode[]): boolean;
|
|
280
179
|
/**
|
|
281
|
-
* Inserts
|
|
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
|
|
184
|
+
export function insertXObjElements(obj: INode, ...args: insertListOfElementsParams): number;
|
|
185
|
+
type insertListOfElementsParams = [ ...names: string[], options: OPT_inselops_L];
|