@ygracs/chn-alias-list 0.0.8 → 0.0.9
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 +15 -0
- package/doc/chn-alias-list.md +149 -79
- package/index.d.ts +8 -7
- package/index.js +18 -6
- package/lib/chn-alias-list.d.ts +23 -111
- package/lib/chn-alias-list.js +64 -309
- package/lib/chn-names.d.ts +146 -0
- package/lib/chn-names.js +392 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
#### *v0.0.9*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - update `chn-alias-list.md`;
|
|
6
|
+
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.4.0;
|
|
7
|
+
> - update dependency on `@cntwg/file-helper` module to v0.0.4;
|
|
8
|
+
> - (TChnAliasList) add method: `checkIndex`, `tryIndex`;
|
|
9
|
+
> - (TChnAliasList) deprecate method: `chkIndex`;
|
|
10
|
+
> - (TChnAliasList) change method behavior: `loadItems`;
|
|
11
|
+
> - (TChnNamesList) add method: `checkIndex`, `tryIndex`;
|
|
12
|
+
> - (TChnNamesList) deprecate method: `chkIndex`;
|
|
13
|
+
> - (TChnNamesList) change method behavior: `loadItems`;
|
|
14
|
+
> - some fixes.
|
|
15
|
+
|
|
1
16
|
#### *v0.0.8*
|
|
2
17
|
|
|
3
18
|
Pre-release version.
|
package/doc/chn-alias-list.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
>|***rev.*:**|0.0.
|
|
2
|
+
>|***rev.*:**|0.0.10|
|
|
3
3
|
>|:---|---:|
|
|
4
|
-
>|date:|2026-
|
|
4
|
+
>|date:|2026-06-28|
|
|
5
5
|
|
|
6
6
|
## Introduction
|
|
7
7
|
|
|
@@ -11,6 +11,7 @@ This paper describes a classes and some helper functions provided by `chn-alias-
|
|
|
11
11
|
|
|
12
12
|
- Base types
|
|
13
13
|
- <a href="#typedef+IChannelRecord">IChannelRecord</a>
|
|
14
|
+
- <a href="#typedef+ILangTextPair">ILangTextPair</a>
|
|
14
15
|
- <a href="#typedef+fsoDescr">fsoDescr</a>
|
|
15
16
|
|
|
16
17
|
- Classes
|
|
@@ -27,6 +28,16 @@ This paper describes a classes and some helper functions provided by `chn-alias-
|
|
|
27
28
|
|
|
28
29
|
This section contains some definitions for a general types of the objects (e.g. options set) that frequently used in a function or a class method descriptions.
|
|
29
30
|
|
|
31
|
+
<a name="typedef+ILangTextPair"></a>
|
|
32
|
+
#### `ILangTextPair` => `[ lang, text ]`
|
|
33
|
+
|
|
34
|
+
This type describes a record element, an array of two elements that represents a `<lang>`-`<text>` pair. The structure of an array is listed in the table below:
|
|
35
|
+
|
|
36
|
+
| element name | value type | description |
|
|
37
|
+
|:---|---|:---|
|
|
38
|
+
| `lang` | `string` | a language name |
|
|
39
|
+
| `text` | `any` | a text value |
|
|
40
|
+
|
|
30
41
|
<a name="typedef+IChannelRecord"></a>
|
|
31
42
|
#### `IChannelRecord` - descriptor
|
|
32
43
|
|
|
@@ -36,7 +47,7 @@ This descriptor is an `object` that contains an info of a channel data.
|
|
|
36
47
|
|:---|---|---:|:---|
|
|
37
48
|
| `id` | `string` | no | a channel ID |
|
|
38
49
|
| `alias` | `string` | no | a target ID for a channel |
|
|
39
|
-
| `name` | `
|
|
50
|
+
| `name` | `ILangTextPair[]` | no | a list of a channel names |
|
|
40
51
|
| `status` | `string` | no | a channel status |
|
|
41
52
|
|
|
42
53
|
<a name="typedef+fsoDescr"></a>
|
|
@@ -53,45 +64,45 @@ This descriptor is an `object` that describes a status for an operation with som
|
|
|
53
64
|
| `source` | `string` | yes | path to a file |
|
|
54
65
|
| `content` | `any` | yes | content |
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
### Module classes
|
|
57
68
|
|
|
58
69
|
<a name="TChnNameRecord"></a>
|
|
59
|
-
|
|
70
|
+
#### **TChnNameRecord**
|
|
60
71
|
|
|
61
72
|
This class implements an interface of the name record
|
|
62
73
|
|
|
63
74
|
<a name="new_TChnNameRecord_new"></a>
|
|
64
|
-
|
|
75
|
+
##### class constructor
|
|
65
76
|
|
|
66
77
|
The class constructor creates a new instance of the class. It receives no arguments.
|
|
67
78
|
|
|
68
|
-
|
|
79
|
+
##### class properties
|
|
69
80
|
|
|
70
81
|
<a name="TChnNameRecord+lang"></a>
|
|
71
|
-
|
|
82
|
+
###### **lang**
|
|
72
83
|
|
|
73
84
|
| value type | read only | description |
|
|
74
85
|
|---|---|:---|
|
|
75
86
|
| `string` | yes | defines a language applied to a name record value |
|
|
76
87
|
|
|
77
88
|
<a name="TChnNameRecord+text"></a>
|
|
78
|
-
|
|
89
|
+
###### **text**
|
|
79
90
|
|
|
80
91
|
| value type | read only | description |
|
|
81
92
|
|---|---|:---|
|
|
82
93
|
| `string` | yes | defines a text value of a name record |
|
|
83
94
|
|
|
84
95
|
<a name="TChnNameRecord+value"></a>
|
|
85
|
-
|
|
96
|
+
###### **value**
|
|
86
97
|
|
|
87
98
|
| value type | read only | description |
|
|
88
99
|
|---|---|:---|
|
|
89
|
-
| `
|
|
100
|
+
| `ILangTextPair` | no | defines a value of a name record |
|
|
90
101
|
|
|
91
|
-
|
|
102
|
+
##### class methods
|
|
92
103
|
|
|
93
104
|
<a name="TChnNameRecord+setValue"></a>
|
|
94
|
-
|
|
105
|
+
###### **setValue(data)** => `boolean`
|
|
95
106
|
|
|
96
107
|
This method sets the value of a name record.
|
|
97
108
|
|
|
@@ -100,7 +111,7 @@ This method sets the value of a name record.
|
|
|
100
111
|
| `data` | `any` | --- | a data for a name record to be set |
|
|
101
112
|
|
|
102
113
|
<a name="TChnNameRecord+toFormatString"></a>
|
|
103
|
-
|
|
114
|
+
###### **toFormatString(opt)** => `string`
|
|
104
115
|
|
|
105
116
|
Returns a name record value as a formatted string.
|
|
106
117
|
|
|
@@ -109,50 +120,57 @@ Returns a name record value as a formatted string.
|
|
|
109
120
|
| `opt` | `any` | --- | <*reserved*> |
|
|
110
121
|
|
|
111
122
|
<a name="TChnNameRecord+reset"></a>
|
|
112
|
-
|
|
123
|
+
###### **reset()** => `void`
|
|
113
124
|
|
|
114
125
|
Clears the record.
|
|
115
126
|
|
|
116
127
|
<a name="TChnNamesList"></a>
|
|
117
|
-
|
|
128
|
+
#### **TChnNamesList**
|
|
118
129
|
|
|
119
130
|
This class implements an interface of the name records list.
|
|
120
131
|
|
|
121
132
|
<a name="new_TChnNamesList_new"></a>
|
|
122
|
-
|
|
133
|
+
##### class constructor
|
|
123
134
|
|
|
124
135
|
The class constructor creates a new instance of the class. It receives no arguments.
|
|
125
136
|
|
|
126
|
-
|
|
137
|
+
##### class properties
|
|
127
138
|
|
|
128
139
|
<a name="TChnNamesList+count"></a>
|
|
129
|
-
|
|
140
|
+
###### **count**
|
|
130
141
|
|
|
131
142
|
| value type | read only | description |
|
|
132
143
|
|---|---|:---|
|
|
133
144
|
| `number` | yes | contains a quantity of a name records |
|
|
134
145
|
|
|
135
146
|
<a name="TChnNamesList+value"></a>
|
|
136
|
-
|
|
147
|
+
###### **value**
|
|
137
148
|
|
|
138
149
|
| value type | read only | description |
|
|
139
150
|
|---|---|:---|
|
|
140
|
-
| `
|
|
151
|
+
| `ILangTextPair[]` | yes | contains a list of a name entries |
|
|
141
152
|
|
|
142
|
-
|
|
153
|
+
##### class methods
|
|
143
154
|
|
|
144
155
|
<a name="TChnNamesList+isEmpty"></a>
|
|
145
|
-
|
|
156
|
+
###### **isEmpty()** => `boolean`
|
|
146
157
|
|
|
147
158
|
Returns a flag that indicating whether a list is empty or not.
|
|
148
159
|
|
|
149
160
|
<a name="TChnNamesList+isNotEmpty"></a>
|
|
150
|
-
|
|
161
|
+
###### **isNotEmpty()** => `boolean`
|
|
151
162
|
|
|
152
163
|
Returns a flag that indicating whether a list has any members.
|
|
153
164
|
|
|
154
165
|
<a name="TChnNamesList+chkIndex"></a>
|
|
155
|
-
|
|
166
|
+
###### **chkIndex(value)** => `boolean`
|
|
167
|
+
|
|
168
|
+
> WARNING: \[since `v0.0.9`] this method deprecated (*use [`checkIndex`](#TChnNamesList+checkIndex) method instead*).
|
|
169
|
+
|
|
170
|
+
<a name="TChnNamesList+checkIndex"></a>
|
|
171
|
+
###### **checkIndex(value)** => `boolean`
|
|
172
|
+
|
|
173
|
+
> since: \[`v0.0.9`]
|
|
156
174
|
|
|
157
175
|
Checks whether a given value is an index and fits
|
|
158
176
|
an Index range within the instance.
|
|
159
177
|
|
|
@@ -160,8 +178,19 @@ Checks whether a given value is an index and fits
|
|
|
160
178
|
an Index range within the ins
|
|
161
179
|
|:---|---|---:|:---|
|
|
162
180
|
| `value` | `any` | --- | a value to be verified |
|
|
163
181
|
|
|
182
|
+
<a name="TChnNamesList+tryIndex"></a>
|
|
183
|
+
###### **tryIndex(value)** => `number`
|
|
184
|
+
|
|
185
|
+
> since: \[`v0.0.9`]
|
|
186
|
+
|
|
187
|
+
This method evaluates whether the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so an index value returned. If failed a `-1` will be returned.
|
|
188
|
+
|
|
189
|
+
| parameter name | value type | default value | description |
|
|
190
|
+
|:---|---|---:|:---|
|
|
191
|
+
| `value` | `any` | --- | a value to be verified |
|
|
192
|
+
|
|
164
193
|
<a name="TChnNamesList+getIndex"></a>
|
|
165
|
-
|
|
194
|
+
###### **getIndex(value)** => `number`
|
|
166
195
|
|
|
167
196
|
Searches an index of a given name in the list.
|
|
168
197
|
|
|
@@ -170,7 +199,7 @@ Searches an index of a given name in the list.
|
|
|
170
199
|
| `value` | `string` | --- | a name to be searched |
|
|
171
200
|
|
|
172
201
|
<a name="TChnNamesList+getItem"></a>
|
|
173
|
-
|
|
202
|
+
###### **getItem(value)** => `?TChnNameRecord`
|
|
174
203
|
|
|
175
204
|
> since: \[v0.0.5]
|
|
176
205
|
|
|
@@ -181,7 +210,7 @@ Returns a name record addressed by a given index.
|
|
|
181
210
|
| `value` | `number` | --- | an element index in the list |
|
|
182
211
|
|
|
183
212
|
<a name="TChnNamesList+addItem"></a>
|
|
184
|
-
|
|
213
|
+
###### **addItem(data)** => `boolean`
|
|
185
214
|
|
|
186
215
|
> since: \[v0.0.5]
|
|
187
216
|
|
|
@@ -192,7 +221,7 @@ Adds a new name record to a list members.
|
|
|
192
221
|
| `data` | `any` | --- | a data for a name record to be added in the list |
|
|
193
222
|
|
|
194
223
|
<a name="TChnNamesList+delItem"></a>
|
|
195
|
-
|
|
224
|
+
###### **delItem(value)** => `boolean`
|
|
196
225
|
|
|
197
226
|
> since: \[v0.0.5]
|
|
198
227
|
|
|
@@ -203,7 +232,7 @@ Tries to delete a name record addressed by a given index.
|
|
|
203
232
|
| `value` | `number` | --- | an element index in the list |
|
|
204
233
|
|
|
205
234
|
<a name="TChnNamesList+loadItems"></a>
|
|
206
|
-
|
|
235
|
+
###### **loadItems(list, \[options])** => `number`
|
|
207
236
|
|
|
208
237
|
> since: \[v0.0.5]
|
|
209
238
|
|
|
@@ -212,15 +241,27 @@ Loads a list of a new name records.
|
|
|
212
241
|
| parameter name | value type | default value | description |
|
|
213
242
|
|:---|---|---:|:---|
|
|
214
243
|
| `list` | `array` | --- | a list of an elements to load |
|
|
215
|
-
| `
|
|
244
|
+
| `options` | `boolean` or `object` | `true` | load options |
|
|
245
|
+
|
|
246
|
+
###### ***`options` parameter***
|
|
247
|
+
|
|
248
|
+
The `options` parameter is a `boolean` on an `object`.
|
|
249
|
+
|
|
250
|
+
If `options` parameter is a `boolean` it treats as a `useClear` option.
|
|
251
|
+
|
|
252
|
+
\[**since: `v0.0.9`**] If `options` parameter is an `object` it may contains the following set of parameters:
|
|
253
|
+
|
|
254
|
+
| option name | value type | default value | description |
|
|
255
|
+
|:---|---|---:|:---|
|
|
256
|
+
| `useClear` | `boolean` | `true` | if set to `true`, before the load, the list is cleared |
|
|
216
257
|
|
|
217
258
|
<a name="TChnNamesList+clear"></a>
|
|
218
|
-
|
|
259
|
+
###### **clear()** => `void`
|
|
219
260
|
|
|
220
261
|
Removes all of the instance members.
|
|
221
262
|
|
|
222
263
|
<a name="TChnNamesList+forEach"></a>
|
|
223
|
-
|
|
264
|
+
###### **forEach(cb)** => `void`
|
|
224
265
|
|
|
225
266
|
Calls a given function upon each name record in the list.
|
|
226
267
|
|
|
@@ -229,7 +270,7 @@ Calls a given function upon each name record in the list.
|
|
|
229
270
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
230
271
|
|
|
231
272
|
<a name="TChnNamesList+filter"></a>
|
|
232
|
-
|
|
273
|
+
###### **filter(cb)** => `TChnNameRecord[]`
|
|
233
274
|
|
|
234
275
|
> since: \[v0.0.5]
|
|
235
276
|
|
|
@@ -240,49 +281,49 @@ Returns an array of a name records picked up by a given function.
|
|
|
240
281
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
241
282
|
|
|
242
283
|
<a name="TChnAliasItem"></a>
|
|
243
|
-
|
|
284
|
+
#### **TChnAliasItem**
|
|
244
285
|
|
|
245
286
|
This class implements an interface of the channel item.
|
|
246
287
|
|
|
247
288
|
<a name="new_TChnAliasItem_new"></a>
|
|
248
|
-
|
|
289
|
+
##### class constructor
|
|
249
290
|
|
|
250
291
|
The class constructor creates a new instance of the class. It receives no arguments.
|
|
251
292
|
|
|
252
|
-
|
|
293
|
+
##### class properties
|
|
253
294
|
|
|
254
295
|
<a name="TChnAliasItem+id"></a>
|
|
255
|
-
|
|
296
|
+
###### **id**
|
|
256
297
|
|
|
257
298
|
| value type | read only | description |
|
|
258
299
|
|---|---|:---|
|
|
259
300
|
| `string` | no | defines a channel ID |
|
|
260
301
|
|
|
261
302
|
<a name="TChnAliasItem+alias"></a>
|
|
262
|
-
|
|
303
|
+
###### **alias**
|
|
263
304
|
|
|
264
305
|
| value type | read only | description |
|
|
265
306
|
|---|---|:---|
|
|
266
307
|
| `string` | no | defines a channel alias |
|
|
267
308
|
|
|
268
309
|
<a name="TChnAliasItem+names"></a>
|
|
269
|
-
|
|
310
|
+
###### **names**
|
|
270
311
|
|
|
271
312
|
| value type | read only | description |
|
|
272
313
|
|---|---|:---|
|
|
273
314
|
| `TChnNamesList` | yes | contains a list of a name records |
|
|
274
315
|
|
|
275
316
|
<a name="TChnAliasItem+status"></a>
|
|
276
|
-
|
|
317
|
+
###### **status**
|
|
277
318
|
|
|
278
319
|
| value type | read only | description |
|
|
279
320
|
|---|---|:---|
|
|
280
321
|
| `string` | yes | defines an instance status |
|
|
281
322
|
|
|
282
|
-
|
|
323
|
+
##### class methods
|
|
283
324
|
|
|
284
325
|
<a name="TChnAliasItem+setID"></a>
|
|
285
|
-
|
|
326
|
+
###### **setID(value)** => `boolean`
|
|
286
327
|
|
|
287
328
|
Sets a channel ID.
|
|
288
329
|
|
|
@@ -291,7 +332,7 @@ Sets a channel ID.
|
|
|
291
332
|
| `value` | `string` | --- | a channel ID |
|
|
292
333
|
|
|
293
334
|
<a name="TChnAliasItem+setAlias"></a>
|
|
294
|
-
|
|
335
|
+
###### **setAlias(value)** => `boolean`
|
|
295
336
|
|
|
296
337
|
Sets a channel alias.
|
|
297
338
|
|
|
@@ -300,39 +341,39 @@ Sets a channel alias.
|
|
|
300
341
|
| `value` | `string` | --- | a channel alias |
|
|
301
342
|
|
|
302
343
|
<a name="TChnAliasItem+addName"></a>
|
|
303
|
-
|
|
344
|
+
###### **addName(data)** => `boolean`
|
|
304
345
|
|
|
305
346
|
> \[!] NOTE: `[since v0.0.7]` deprecated. Use [`TChnNamesList.addItem`](#TChnNamesList+addItem) instead.
|
|
306
347
|
|
|
307
348
|
<a name="TChnAliasItem+loadNames"></a>
|
|
308
|
-
|
|
349
|
+
###### **loadNames(list, \[opt])** => `number`
|
|
309
350
|
|
|
310
351
|
> \[!] NOTE: `[since v0.0.7]` deprecated. Use [`TChnNamesList.loadItems`](#TChnNamesList+loadItems) instead.
|
|
311
352
|
|
|
312
353
|
<a name="TChnAliasItem+enable"></a>
|
|
313
|
-
|
|
354
|
+
###### **enable()** => `void`
|
|
314
355
|
|
|
315
356
|
Sets item status to "enabled".
|
|
316
357
|
|
|
317
358
|
<a name="TChnAliasItem+disable"></a>
|
|
318
|
-
|
|
359
|
+
###### **disable()** => `void`
|
|
319
360
|
|
|
320
361
|
Sets item status to "disabled".
|
|
321
362
|
|
|
322
363
|
<a name="TChnAliasItem+up"></a>
|
|
323
|
-
|
|
364
|
+
###### **up()** => `void`
|
|
324
365
|
|
|
325
366
|
Sets item status to "active"/"running".
|
|
326
367
|
|
|
327
368
|
<a name="TChnAliasItem+down"></a>
|
|
328
|
-
|
|
369
|
+
###### **down()** => `void`
|
|
329
370
|
|
|
330
371
|
Sets item status to "inactive"/"stopped".
|
|
331
372
|
|
|
332
|
-
|
|
373
|
+
##### class methods
|
|
333
374
|
|
|
334
375
|
<a name="TChnAliasItem+setStatus"></a>
|
|
335
|
-
|
|
376
|
+
###### **setStatus(value)** => `boolean`
|
|
336
377
|
|
|
337
378
|
Sets item status.
|
|
338
379
|
|
|
@@ -340,17 +381,17 @@ Sets item status.
|
|
|
340
381
|
|:---|---|---:|:---|
|
|
341
382
|
| `value` | `string` | --- | a name of predefined status value (a possible value may be: `enabled`, `disabled`, `up` or `down`) |
|
|
342
383
|
|
|
343
|
-
|
|
384
|
+
##### class methods (*special*)
|
|
344
385
|
|
|
345
386
|
<a name="TChnAliasItem+toJSON"></a>
|
|
346
|
-
|
|
387
|
+
###### **toJSON()** => `IChannelRecord`
|
|
347
388
|
|
|
348
389
|
A special method that provides an interface to an instance representation
|
|
349
390
|
for a `JSON.stringify()`.
|
|
350
391
|
|
|
351
|
-
|
|
392
|
+
##### class methods (*static*)
|
|
352
393
|
|
|
353
394
|
<a name="TChnAliasItem.create"></a>
|
|
354
|
-
|
|
395
|
+
###### **create(obj)** => `?TChnAliasItem`
|
|
355
396
|
|
|
356
397
|
Creates a new alias element.
|
|
357
398
|
|
|
@@ -359,48 +400,65 @@ Creates a new alias element.
|
|
|
359
400
|
| `obj` | `IChannelRecord` | --- | an initial data |
|
|
360
401
|
|
|
361
402
|
<a name="TChnAliasList"></a>
|
|
362
|
-
|
|
403
|
+
#### **TChnAliasList**
|
|
363
404
|
|
|
364
405
|
This class implements an interface of the channel items list.
|
|
365
406
|
|
|
366
407
|
<a name="new_TChnAliasList_new"></a>
|
|
367
|
-
|
|
408
|
+
##### class constructor
|
|
368
409
|
|
|
369
410
|
The class constructor creates a new instance of the class. It receives no arguments.
|
|
370
411
|
|
|
371
|
-
|
|
412
|
+
##### class properties
|
|
372
413
|
|
|
373
414
|
<a name="TChnAliasList+count"></a>
|
|
374
|
-
|
|
415
|
+
###### **count**
|
|
375
416
|
|
|
376
417
|
| value type | read only | description |
|
|
377
418
|
|---|---|:---|
|
|
378
419
|
| `number` | yes | contains a quantity of the elements |
|
|
379
420
|
|
|
380
|
-
|
|
421
|
+
##### class methods
|
|
381
422
|
|
|
382
423
|
<a name="TChnAliasList+isEmpty"></a>
|
|
383
|
-
|
|
424
|
+
###### **isEmpty()** => `boolean`
|
|
384
425
|
|
|
385
426
|
Returns a flag that indicating whether a list is empty or not.
|
|
386
427
|
|
|
387
428
|
<a name="TChnAliasList+isNotEmpty"></a>
|
|
388
|
-
|
|
429
|
+
###### **isNotEmpty()** => `boolean`
|
|
389
430
|
|
|
390
431
|
Returns a flag that indicating whether a list has any members.
|
|
391
432
|
|
|
392
433
|
<a name="TChnAliasList+chkIndex"></a>
|
|
393
|
-
|
|
434
|
+
###### **chkIndex(value)** => `boolean`
|
|
435
|
+
|
|
436
|
+
> WARNING: \[since `v0.0.9`] this method deprecated (*use [`checkIndex`](#TChnAliasList+checkIndex) method instead*).
|
|
437
|
+
|
|
438
|
+
<a name="TChnAliasList+checkIndex"></a>
|
|
439
|
+
###### **checkIndex(value)** => `boolean`
|
|
394
440
|
|
|
395
|
-
|
|
396
|
-
|
|
441
|
+
> since: \[`v0.0.9`]
|
|
442
|
+
|
|
443
|
+
Checks whether a given value is an index and fits an Index range within the instance.
|
|
444
|
+
|
|
445
|
+
| parameter name | value type | default value | description |
|
|
446
|
+
|:---|---|---:|:---|
|
|
447
|
+
| `value` | `any` | --- | a value to be verified |
|
|
448
|
+
|
|
449
|
+
<a name="TChnAliasList+tryIndex"></a>
|
|
450
|
+
###### **tryIndex(value)** => `number`
|
|
451
|
+
|
|
452
|
+
> since: \[`v0.0.9`]
|
|
453
|
+
|
|
454
|
+
This method evaluates whether the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so an index value returned. If failed a `-1` will be returned.
|
|
397
455
|
|
|
398
456
|
| parameter name | value type | default value | description |
|
|
399
457
|
|:---|---|---:|:---|
|
|
400
458
|
| `value` | `any` | --- | a value to be verified |
|
|
401
459
|
|
|
402
460
|
<a name="TChnAliasList+searchIndexByID"></a>
|
|
403
|
-
|
|
461
|
+
###### **searchIndexByID(value)** => `number`
|
|
404
462
|
|
|
405
463
|
Searches an index of an element by its given ID.
|
|
406
464
|
|
|
@@ -409,7 +467,7 @@ Searches an index of an element by its given ID.
|
|
|
409
467
|
| `value` | `string` | --- | a value of ID to be searched |
|
|
410
468
|
|
|
411
469
|
<a name="TChnAliasList+getItem"></a>
|
|
412
|
-
|
|
470
|
+
###### **getItem(value)** => `?TChnAliasItem`
|
|
413
471
|
|
|
414
472
|
Returns an alias element by its index.
|
|
415
473
|
|
|
@@ -418,7 +476,7 @@ Returns an alias element by its index.
|
|
|
418
476
|
| `value` | `number` | --- | an element index |
|
|
419
477
|
|
|
420
478
|
<a name="TChnAliasList+getItemByID"></a>
|
|
421
|
-
|
|
479
|
+
###### **getItemByID(value)** => `?TChnAliasItem`
|
|
422
480
|
|
|
423
481
|
Returns an alias element by its ID.
|
|
424
482
|
|
|
@@ -427,7 +485,7 @@ Returns an alias element by its ID.
|
|
|
427
485
|
| `value` | `string` | --- | an element ID |
|
|
428
486
|
|
|
429
487
|
<a name="TChnAliasList+addItem"></a>
|
|
430
|
-
|
|
488
|
+
###### **addItem(obj)** => `number`
|
|
431
489
|
|
|
432
490
|
Adds an alias element.
|
|
433
491
|
|
|
@@ -436,7 +494,7 @@ Adds an alias element.
|
|
|
436
494
|
| `obj` | `IChannelRecord` | --- | an element to be added |
|
|
437
495
|
|
|
438
496
|
<a name="TChnAliasList+delItem"></a>
|
|
439
|
-
|
|
497
|
+
###### **delItem(value)** => `boolean`
|
|
440
498
|
|
|
441
499
|
Tries to delete an element addressed by a given index.
|
|
442
500
|
|
|
@@ -445,22 +503,34 @@ Tries to delete an element addressed by a given index.
|
|
|
445
503
|
| `value` | `number` | --- | an element index |
|
|
446
504
|
|
|
447
505
|
<a name="TChnAliasList+loadItems"></a>
|
|
448
|
-
|
|
506
|
+
###### **loadItems(list, \[options])** => `number`
|
|
449
507
|
|
|
450
508
|
Loads a list of a new alias elements.
|
|
451
509
|
|
|
452
510
|
| parameter name | value type | default value | description |
|
|
453
511
|
|:---|---|---:|:---|
|
|
454
512
|
| `list` | `IChannelRecord[]` | --- | a list of an elements |
|
|
455
|
-
| `
|
|
513
|
+
| `options` | `boolean` or `object` | `true` | load options |
|
|
514
|
+
|
|
515
|
+
###### ***`options` parameter***
|
|
516
|
+
|
|
517
|
+
The `options` parameter is a `boolean` on an `object`.
|
|
518
|
+
|
|
519
|
+
If `options` parameter is a `boolean` it treats as a `useClear` option.
|
|
520
|
+
|
|
521
|
+
\[**since: `v0.0.9`**] If `options` parameter is an `object` it may contains the following set of parameters:
|
|
522
|
+
|
|
523
|
+
| option name | value type | default value | description |
|
|
524
|
+
|:---|---|---:|:---|
|
|
525
|
+
| `useClear` | `boolean` | `true` | if set to `true`, before the load, the list is cleared |
|
|
456
526
|
|
|
457
527
|
<a name="TChnAliasList+clear"></a>
|
|
458
|
-
|
|
528
|
+
###### **clear()** => `void`
|
|
459
529
|
|
|
460
530
|
Removes all of the instance members.
|
|
461
531
|
|
|
462
532
|
<a name="TChnAliasList+forEach"></a>
|
|
463
|
-
|
|
533
|
+
###### **forEach(cb)** => `void`
|
|
464
534
|
|
|
465
535
|
Calls given function for each alias element in the list.
|
|
466
536
|
|
|
@@ -469,7 +539,7 @@ Calls given function for each alias element in the list.
|
|
|
469
539
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
470
540
|
|
|
471
541
|
<a name="TChnAliasList+filter"></a>
|
|
472
|
-
|
|
542
|
+
###### **filter(cb)** => `TChnAliasItem[]`
|
|
473
543
|
|
|
474
544
|
> since: \[v0.0.5]
|
|
475
545
|
|
|
@@ -479,10 +549,10 @@ Returns an array of a channel items picked up by a given function.
|
|
|
479
549
|
|:---|---|---:|:---|
|
|
480
550
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
481
551
|
|
|
482
|
-
|
|
552
|
+
### Module functions
|
|
483
553
|
|
|
484
554
|
<a name="loadAliasFromFileSync"></a>
|
|
485
|
-
|
|
555
|
+
##### **loadAliasFromFileSync(src, [opt])** => `object`
|
|
486
556
|
|
|
487
557
|
Loads an alias data from a file.
|
|
488
558
|
|
|
@@ -492,7 +562,7 @@ Loads an alias data from a file.
|
|
|
492
562
|
| `opt` | `any` | --- | <*reserved*> |
|
|
493
563
|
|
|
494
564
|
<a name="saveAliasToFileSync"></a>
|
|
495
|
-
|
|
565
|
+
##### **saveAliasToFileSync(src, content, [opt])** => `fsoDescr`
|
|
496
566
|
|
|
497
567
|
Saves an alias data to a file.
|
|
498
568
|
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
1
|
+
import { TChnNameRecord } from "./lib/chn-names";
|
|
2
|
+
import { TChnNamesList } from "./lib/chn-names";
|
|
3
|
+
import { TChnAliasItem } from "./lib/chn-alias-list";
|
|
4
|
+
import { TChnAliasList } from "./lib/chn-alias-list";
|
|
5
|
+
import type { fsoDescr } from "@cntwg/file-helper";
|
|
6
|
+
import type { ILangTextPair } from "./lib/chn-names";
|
|
7
|
+
import type { IChannelRecord } from "./lib/chn-alias-list";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
loadAliasFromFileSync, saveAliasToFileSync,
|
|
@@ -19,6 +19,7 @@ export {
|
|
|
19
19
|
|
|
20
20
|
export type {
|
|
21
21
|
fsoDescr,
|
|
22
|
+
ILangTextPair,
|
|
22
23
|
IChannelRecord,
|
|
23
24
|
RVAL_loadaliasff,
|
|
24
25
|
};
|
package/index.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
// [v0.
|
|
1
|
+
// [v0.2.004-20260628]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const {
|
|
6
|
+
TChnAliasItem, TChnAliasList,
|
|
7
|
+
// * import types definitions *
|
|
8
|
+
IChannelRecord,
|
|
9
|
+
} = require('./lib/chn-alias-list');
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
TChnNameRecord, TChnNamesList,
|
|
13
|
+
// * import types definitions *
|
|
14
|
+
ILangTextPair,
|
|
15
|
+
} = require('./lib/chn-names');
|
|
6
16
|
|
|
7
17
|
const fileHelper = require('./lib/file-helper-ext');
|
|
8
18
|
|
|
@@ -17,10 +27,10 @@ const {
|
|
|
17
27
|
|
|
18
28
|
// === module exports block ===
|
|
19
29
|
|
|
20
|
-
module.exports.TChnNameRecord =
|
|
21
|
-
module.exports.TChnNamesList =
|
|
22
|
-
module.exports.TChnAliasItem =
|
|
23
|
-
module.exports.TChnAliasList =
|
|
30
|
+
module.exports.TChnNameRecord = TChnNameRecord;
|
|
31
|
+
module.exports.TChnNamesList = TChnNamesList;
|
|
32
|
+
module.exports.TChnAliasItem = TChnAliasItem;
|
|
33
|
+
module.exports.TChnAliasList = TChnAliasList;
|
|
24
34
|
|
|
25
35
|
module.exports.loadAliasFromFileSync = fileHelper.loadAliasFromFileSync;
|
|
26
36
|
module.exports.saveAliasToFileSync = fileHelper.saveAliasToFileSync;
|
|
@@ -28,3 +38,5 @@ module.exports.saveAliasToFileSync = fileHelper.saveAliasToFileSync;
|
|
|
28
38
|
// * export types definitions *
|
|
29
39
|
// @ts-ignore
|
|
30
40
|
module.exports.fsoDescr = fsoDescr;
|
|
41
|
+
module.exports.ILangTextPair = ILangTextPair;
|
|
42
|
+
module.exports.IChannelRecord = IChannelRecord;
|