@ygracs/chn-alias-list 0.0.7 → 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 +23 -0
- package/doc/chn-alias-list.md +149 -99
- package/index.d.ts +8 -7
- package/index.js +18 -6
- package/lib/chn-alias-list.d.ts +23 -135
- package/lib/chn-alias-list.js +66 -366
- package/lib/chn-names.d.ts +146 -0
- package/lib/chn-names.js +392 -0
- package/lib/file-helper-ext.js +2 -17
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
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
|
+
|
|
16
|
+
#### *v0.0.8*
|
|
17
|
+
|
|
18
|
+
Pre-release version.
|
|
19
|
+
|
|
20
|
+
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.4;
|
|
21
|
+
> - (TChnNamesList) remove deprecated method: `getName`, `addName`, `delName`, `loadNames`;
|
|
22
|
+
> - some fixes.
|
|
23
|
+
|
|
1
24
|
#### *v0.0.7*
|
|
2
25
|
|
|
3
26
|
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
|
|
|
@@ -169,13 +198,8 @@ Searches an index of a given name in the list.
|
|
|
169
198
|
|:---|---|---:|:---|
|
|
170
199
|
| `value` | `string` | --- | a name to be searched |
|
|
171
200
|
|
|
172
|
-
<a name="TChnNamesList+getName"></a>
|
|
173
|
-
##### **getName(value)** => `?TChnNameRecord`
|
|
174
|
-
|
|
175
|
-
> \[!] NOTE: `[since v0.0.5]` deprecated. Use `getItem` instead.
|
|
176
|
-
|
|
177
201
|
<a name="TChnNamesList+getItem"></a>
|
|
178
|
-
|
|
202
|
+
###### **getItem(value)** => `?TChnNameRecord`
|
|
179
203
|
|
|
180
204
|
> since: \[v0.0.5]
|
|
181
205
|
|
|
@@ -185,13 +209,8 @@ Returns a name record addressed by a given index.
|
|
|
185
209
|
|:---|---|---:|:---|
|
|
186
210
|
| `value` | `number` | --- | an element index in the list |
|
|
187
211
|
|
|
188
|
-
<a name="TChnNamesList+addName"></a>
|
|
189
|
-
#### **addName(data)** => `boolean`
|
|
190
|
-
|
|
191
|
-
> \[!] NOTE: `[since v0.0.5]` deprecated. Use `addItem` instead.
|
|
192
|
-
|
|
193
212
|
<a name="TChnNamesList+addItem"></a>
|
|
194
|
-
|
|
213
|
+
###### **addItem(data)** => `boolean`
|
|
195
214
|
|
|
196
215
|
> since: \[v0.0.5]
|
|
197
216
|
|
|
@@ -201,13 +220,8 @@ Adds a new name record to a list members.
|
|
|
201
220
|
|:---|---|---:|:---|
|
|
202
221
|
| `data` | `any` | --- | a data for a name record to be added in the list |
|
|
203
222
|
|
|
204
|
-
<a name="TChnNamesList+delName"></a>
|
|
205
|
-
##### **delName(value)** => `boolean`
|
|
206
|
-
|
|
207
|
-
> \[!] NOTE: `[since v0.0.5]` deprecated. Use `delItem` instead.
|
|
208
|
-
|
|
209
223
|
<a name="TChnNamesList+delItem"></a>
|
|
210
|
-
|
|
224
|
+
###### **delItem(value)** => `boolean`
|
|
211
225
|
|
|
212
226
|
> since: \[v0.0.5]
|
|
213
227
|
|
|
@@ -217,13 +231,8 @@ Tries to delete a name record addressed by a given index.
|
|
|
217
231
|
|:---|---|---:|:---|
|
|
218
232
|
| `value` | `number` | --- | an element index in the list |
|
|
219
233
|
|
|
220
|
-
<a name="TChnNamesList+loadNames"></a>
|
|
221
|
-
##### **loadNames(list, \[opt])** => `number`
|
|
222
|
-
|
|
223
|
-
> \[!] NOTE: `[since v0.0.5]` deprecated. Use `loadItems` instead.
|
|
224
|
-
|
|
225
234
|
<a name="TChnNamesList+loadItems"></a>
|
|
226
|
-
|
|
235
|
+
###### **loadItems(list, \[options])** => `number`
|
|
227
236
|
|
|
228
237
|
> since: \[v0.0.5]
|
|
229
238
|
|
|
@@ -232,15 +241,27 @@ Loads a list of a new name records.
|
|
|
232
241
|
| parameter name | value type | default value | description |
|
|
233
242
|
|:---|---|---:|:---|
|
|
234
243
|
| `list` | `array` | --- | a list of an elements to load |
|
|
235
|
-
| `
|
|
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 |
|
|
236
257
|
|
|
237
258
|
<a name="TChnNamesList+clear"></a>
|
|
238
|
-
|
|
259
|
+
###### **clear()** => `void`
|
|
239
260
|
|
|
240
261
|
Removes all of the instance members.
|
|
241
262
|
|
|
242
263
|
<a name="TChnNamesList+forEach"></a>
|
|
243
|
-
|
|
264
|
+
###### **forEach(cb)** => `void`
|
|
244
265
|
|
|
245
266
|
Calls a given function upon each name record in the list.
|
|
246
267
|
|
|
@@ -249,7 +270,7 @@ Calls a given function upon each name record in the list.
|
|
|
249
270
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
250
271
|
|
|
251
272
|
<a name="TChnNamesList+filter"></a>
|
|
252
|
-
|
|
273
|
+
###### **filter(cb)** => `TChnNameRecord[]`
|
|
253
274
|
|
|
254
275
|
> since: \[v0.0.5]
|
|
255
276
|
|
|
@@ -260,49 +281,49 @@ Returns an array of a name records picked up by a given function.
|
|
|
260
281
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
261
282
|
|
|
262
283
|
<a name="TChnAliasItem"></a>
|
|
263
|
-
|
|
284
|
+
#### **TChnAliasItem**
|
|
264
285
|
|
|
265
286
|
This class implements an interface of the channel item.
|
|
266
287
|
|
|
267
288
|
<a name="new_TChnAliasItem_new"></a>
|
|
268
|
-
|
|
289
|
+
##### class constructor
|
|
269
290
|
|
|
270
291
|
The class constructor creates a new instance of the class. It receives no arguments.
|
|
271
292
|
|
|
272
|
-
|
|
293
|
+
##### class properties
|
|
273
294
|
|
|
274
295
|
<a name="TChnAliasItem+id"></a>
|
|
275
|
-
|
|
296
|
+
###### **id**
|
|
276
297
|
|
|
277
298
|
| value type | read only | description |
|
|
278
299
|
|---|---|:---|
|
|
279
300
|
| `string` | no | defines a channel ID |
|
|
280
301
|
|
|
281
302
|
<a name="TChnAliasItem+alias"></a>
|
|
282
|
-
|
|
303
|
+
###### **alias**
|
|
283
304
|
|
|
284
305
|
| value type | read only | description |
|
|
285
306
|
|---|---|:---|
|
|
286
307
|
| `string` | no | defines a channel alias |
|
|
287
308
|
|
|
288
309
|
<a name="TChnAliasItem+names"></a>
|
|
289
|
-
|
|
310
|
+
###### **names**
|
|
290
311
|
|
|
291
312
|
| value type | read only | description |
|
|
292
313
|
|---|---|:---|
|
|
293
314
|
| `TChnNamesList` | yes | contains a list of a name records |
|
|
294
315
|
|
|
295
316
|
<a name="TChnAliasItem+status"></a>
|
|
296
|
-
|
|
317
|
+
###### **status**
|
|
297
318
|
|
|
298
319
|
| value type | read only | description |
|
|
299
320
|
|---|---|:---|
|
|
300
321
|
| `string` | yes | defines an instance status |
|
|
301
322
|
|
|
302
|
-
|
|
323
|
+
##### class methods
|
|
303
324
|
|
|
304
325
|
<a name="TChnAliasItem+setID"></a>
|
|
305
|
-
|
|
326
|
+
###### **setID(value)** => `boolean`
|
|
306
327
|
|
|
307
328
|
Sets a channel ID.
|
|
308
329
|
|
|
@@ -311,7 +332,7 @@ Sets a channel ID.
|
|
|
311
332
|
| `value` | `string` | --- | a channel ID |
|
|
312
333
|
|
|
313
334
|
<a name="TChnAliasItem+setAlias"></a>
|
|
314
|
-
|
|
335
|
+
###### **setAlias(value)** => `boolean`
|
|
315
336
|
|
|
316
337
|
Sets a channel alias.
|
|
317
338
|
|
|
@@ -320,39 +341,39 @@ Sets a channel alias.
|
|
|
320
341
|
| `value` | `string` | --- | a channel alias |
|
|
321
342
|
|
|
322
343
|
<a name="TChnAliasItem+addName"></a>
|
|
323
|
-
|
|
344
|
+
###### **addName(data)** => `boolean`
|
|
324
345
|
|
|
325
346
|
> \[!] NOTE: `[since v0.0.7]` deprecated. Use [`TChnNamesList.addItem`](#TChnNamesList+addItem) instead.
|
|
326
347
|
|
|
327
348
|
<a name="TChnAliasItem+loadNames"></a>
|
|
328
|
-
|
|
349
|
+
###### **loadNames(list, \[opt])** => `number`
|
|
329
350
|
|
|
330
351
|
> \[!] NOTE: `[since v0.0.7]` deprecated. Use [`TChnNamesList.loadItems`](#TChnNamesList+loadItems) instead.
|
|
331
352
|
|
|
332
353
|
<a name="TChnAliasItem+enable"></a>
|
|
333
|
-
|
|
354
|
+
###### **enable()** => `void`
|
|
334
355
|
|
|
335
356
|
Sets item status to "enabled".
|
|
336
357
|
|
|
337
358
|
<a name="TChnAliasItem+disable"></a>
|
|
338
|
-
|
|
359
|
+
###### **disable()** => `void`
|
|
339
360
|
|
|
340
361
|
Sets item status to "disabled".
|
|
341
362
|
|
|
342
363
|
<a name="TChnAliasItem+up"></a>
|
|
343
|
-
|
|
364
|
+
###### **up()** => `void`
|
|
344
365
|
|
|
345
366
|
Sets item status to "active"/"running".
|
|
346
367
|
|
|
347
368
|
<a name="TChnAliasItem+down"></a>
|
|
348
|
-
|
|
369
|
+
###### **down()** => `void`
|
|
349
370
|
|
|
350
371
|
Sets item status to "inactive"/"stopped".
|
|
351
372
|
|
|
352
|
-
|
|
373
|
+
##### class methods
|
|
353
374
|
|
|
354
375
|
<a name="TChnAliasItem+setStatus"></a>
|
|
355
|
-
|
|
376
|
+
###### **setStatus(value)** => `boolean`
|
|
356
377
|
|
|
357
378
|
Sets item status.
|
|
358
379
|
|
|
@@ -360,17 +381,17 @@ Sets item status.
|
|
|
360
381
|
|:---|---|---:|:---|
|
|
361
382
|
| `value` | `string` | --- | a name of predefined status value (a possible value may be: `enabled`, `disabled`, `up` or `down`) |
|
|
362
383
|
|
|
363
|
-
|
|
384
|
+
##### class methods (*special*)
|
|
364
385
|
|
|
365
386
|
<a name="TChnAliasItem+toJSON"></a>
|
|
366
|
-
|
|
387
|
+
###### **toJSON()** => `IChannelRecord`
|
|
367
388
|
|
|
368
389
|
A special method that provides an interface to an instance representation
|
|
369
390
|
for a `JSON.stringify()`.
|
|
370
391
|
|
|
371
|
-
|
|
392
|
+
##### class methods (*static*)
|
|
372
393
|
|
|
373
394
|
<a name="TChnAliasItem.create"></a>
|
|
374
|
-
|
|
395
|
+
###### **create(obj)** => `?TChnAliasItem`
|
|
375
396
|
|
|
376
397
|
Creates a new alias element.
|
|
377
398
|
|
|
@@ -379,48 +400,65 @@ Creates a new alias element.
|
|
|
379
400
|
| `obj` | `IChannelRecord` | --- | an initial data |
|
|
380
401
|
|
|
381
402
|
<a name="TChnAliasList"></a>
|
|
382
|
-
|
|
403
|
+
#### **TChnAliasList**
|
|
383
404
|
|
|
384
405
|
This class implements an interface of the channel items list.
|
|
385
406
|
|
|
386
407
|
<a name="new_TChnAliasList_new"></a>
|
|
387
|
-
|
|
408
|
+
##### class constructor
|
|
388
409
|
|
|
389
410
|
The class constructor creates a new instance of the class. It receives no arguments.
|
|
390
411
|
|
|
391
|
-
|
|
412
|
+
##### class properties
|
|
392
413
|
|
|
393
414
|
<a name="TChnAliasList+count"></a>
|
|
394
|
-
|
|
415
|
+
###### **count**
|
|
395
416
|
|
|
396
417
|
| value type | read only | description |
|
|
397
418
|
|---|---|:---|
|
|
398
419
|
| `number` | yes | contains a quantity of the elements |
|
|
399
420
|
|
|
400
|
-
|
|
421
|
+
##### class methods
|
|
401
422
|
|
|
402
423
|
<a name="TChnAliasList+isEmpty"></a>
|
|
403
|
-
|
|
424
|
+
###### **isEmpty()** => `boolean`
|
|
404
425
|
|
|
405
426
|
Returns a flag that indicating whether a list is empty or not.
|
|
406
427
|
|
|
407
428
|
<a name="TChnAliasList+isNotEmpty"></a>
|
|
408
|
-
|
|
429
|
+
###### **isNotEmpty()** => `boolean`
|
|
409
430
|
|
|
410
431
|
Returns a flag that indicating whether a list has any members.
|
|
411
432
|
|
|
412
433
|
<a name="TChnAliasList+chkIndex"></a>
|
|
413
|
-
|
|
434
|
+
###### **chkIndex(value)** => `boolean`
|
|
435
|
+
|
|
436
|
+
> WARNING: \[since `v0.0.9`] this method deprecated (*use [`checkIndex`](#TChnAliasList+checkIndex) method instead*).
|
|
414
437
|
|
|
415
|
-
|
|
416
|
-
|
|
438
|
+
<a name="TChnAliasList+checkIndex"></a>
|
|
439
|
+
###### **checkIndex(value)** => `boolean`
|
|
440
|
+
|
|
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.
|
|
417
455
|
|
|
418
456
|
| parameter name | value type | default value | description |
|
|
419
457
|
|:---|---|---:|:---|
|
|
420
458
|
| `value` | `any` | --- | a value to be verified |
|
|
421
459
|
|
|
422
460
|
<a name="TChnAliasList+searchIndexByID"></a>
|
|
423
|
-
|
|
461
|
+
###### **searchIndexByID(value)** => `number`
|
|
424
462
|
|
|
425
463
|
Searches an index of an element by its given ID.
|
|
426
464
|
|
|
@@ -429,7 +467,7 @@ Searches an index of an element by its given ID.
|
|
|
429
467
|
| `value` | `string` | --- | a value of ID to be searched |
|
|
430
468
|
|
|
431
469
|
<a name="TChnAliasList+getItem"></a>
|
|
432
|
-
|
|
470
|
+
###### **getItem(value)** => `?TChnAliasItem`
|
|
433
471
|
|
|
434
472
|
Returns an alias element by its index.
|
|
435
473
|
|
|
@@ -438,7 +476,7 @@ Returns an alias element by its index.
|
|
|
438
476
|
| `value` | `number` | --- | an element index |
|
|
439
477
|
|
|
440
478
|
<a name="TChnAliasList+getItemByID"></a>
|
|
441
|
-
|
|
479
|
+
###### **getItemByID(value)** => `?TChnAliasItem`
|
|
442
480
|
|
|
443
481
|
Returns an alias element by its ID.
|
|
444
482
|
|
|
@@ -447,7 +485,7 @@ Returns an alias element by its ID.
|
|
|
447
485
|
| `value` | `string` | --- | an element ID |
|
|
448
486
|
|
|
449
487
|
<a name="TChnAliasList+addItem"></a>
|
|
450
|
-
|
|
488
|
+
###### **addItem(obj)** => `number`
|
|
451
489
|
|
|
452
490
|
Adds an alias element.
|
|
453
491
|
|
|
@@ -456,7 +494,7 @@ Adds an alias element.
|
|
|
456
494
|
| `obj` | `IChannelRecord` | --- | an element to be added |
|
|
457
495
|
|
|
458
496
|
<a name="TChnAliasList+delItem"></a>
|
|
459
|
-
|
|
497
|
+
###### **delItem(value)** => `boolean`
|
|
460
498
|
|
|
461
499
|
Tries to delete an element addressed by a given index.
|
|
462
500
|
|
|
@@ -465,22 +503,34 @@ Tries to delete an element addressed by a given index.
|
|
|
465
503
|
| `value` | `number` | --- | an element index |
|
|
466
504
|
|
|
467
505
|
<a name="TChnAliasList+loadItems"></a>
|
|
468
|
-
|
|
506
|
+
###### **loadItems(list, \[options])** => `number`
|
|
469
507
|
|
|
470
508
|
Loads a list of a new alias elements.
|
|
471
509
|
|
|
472
510
|
| parameter name | value type | default value | description |
|
|
473
511
|
|:---|---|---:|:---|
|
|
474
512
|
| `list` | `IChannelRecord[]` | --- | a list of an elements |
|
|
475
|
-
| `
|
|
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 |
|
|
476
526
|
|
|
477
527
|
<a name="TChnAliasList+clear"></a>
|
|
478
|
-
|
|
528
|
+
###### **clear()** => `void`
|
|
479
529
|
|
|
480
530
|
Removes all of the instance members.
|
|
481
531
|
|
|
482
532
|
<a name="TChnAliasList+forEach"></a>
|
|
483
|
-
|
|
533
|
+
###### **forEach(cb)** => `void`
|
|
484
534
|
|
|
485
535
|
Calls given function for each alias element in the list.
|
|
486
536
|
|
|
@@ -489,7 +539,7 @@ Calls given function for each alias element in the list.
|
|
|
489
539
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
490
540
|
|
|
491
541
|
<a name="TChnAliasList+filter"></a>
|
|
492
|
-
|
|
542
|
+
###### **filter(cb)** => `TChnAliasItem[]`
|
|
493
543
|
|
|
494
544
|
> since: \[v0.0.5]
|
|
495
545
|
|
|
@@ -499,10 +549,10 @@ Returns an array of a channel items picked up by a given function.
|
|
|
499
549
|
|:---|---|---:|:---|
|
|
500
550
|
| `cb` | `callback` | --- | a callback function defined by a user |
|
|
501
551
|
|
|
502
|
-
|
|
552
|
+
### Module functions
|
|
503
553
|
|
|
504
554
|
<a name="loadAliasFromFileSync"></a>
|
|
505
|
-
|
|
555
|
+
##### **loadAliasFromFileSync(src, [opt])** => `object`
|
|
506
556
|
|
|
507
557
|
Loads an alias data from a file.
|
|
508
558
|
|
|
@@ -512,7 +562,7 @@ Loads an alias data from a file.
|
|
|
512
562
|
| `opt` | `any` | --- | <*reserved*> |
|
|
513
563
|
|
|
514
564
|
<a name="saveAliasToFileSync"></a>
|
|
515
|
-
|
|
565
|
+
##### **saveAliasToFileSync(src, content, [opt])** => `fsoDescr`
|
|
516
566
|
|
|
517
567
|
Saves an alias data to a file.
|
|
518
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
|
};
|