@ygracs/chn-alias-list 0.0.7-b → 0.0.7
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 +5 -1
- package/doc/chn-alias-list.md +48 -18
- package/index.d.ts +24 -17
- package/lib/chn-alias-list.d.ts +318 -292
- package/lib/chn-alias-list.js +20 -6
- package/lib/file-helper-ext.d.ts +28 -28
- package/lib/file-helper-ext.js +24 -8
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
#### *v0.0.
|
|
1
|
+
#### *v0.0.7*
|
|
2
2
|
|
|
3
3
|
Pre-release version.
|
|
4
4
|
|
|
5
|
+
> - update `chn-alias-list.md`;
|
|
5
6
|
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.3;
|
|
6
7
|
> - update dependency on `@cntwg/file-helper` module to v0.0.3;
|
|
8
|
+
> - improve behavior of `saveAliasToFileSync` on handling `content` param;
|
|
9
|
+
> - deprecate methods: `addName` and `loadNames` of a `TChnAliasItem`-class;
|
|
10
|
+
> - other fixes.
|
|
7
11
|
|
|
8
12
|
#### *v0.0.6*
|
|
9
13
|
|
package/doc/chn-alias-list.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
>|***rev.*:**|0.0.
|
|
2
|
+
>|***rev.*:**|0.0.8|
|
|
3
3
|
>|:---|---:|
|
|
4
|
-
>|date:|
|
|
4
|
+
>|date:|2026-01-30|
|
|
5
5
|
|
|
6
6
|
## Introduction
|
|
7
7
|
|
|
@@ -9,6 +9,10 @@ This paper describes a classes and some helper functions provided by `chn-alias-
|
|
|
9
9
|
|
|
10
10
|
## Content
|
|
11
11
|
|
|
12
|
+
- Base types
|
|
13
|
+
- <a href="#typedef+IChannelRecord">IChannelRecord</a>
|
|
14
|
+
- <a href="#typedef+fsoDescr">fsoDescr</a>
|
|
15
|
+
|
|
12
16
|
- Classes
|
|
13
17
|
- <a href="#TChnNameRecord">TChnNameRecord</a>
|
|
14
18
|
- <a href="#TChnNamesList">TChnNamesList</a>
|
|
@@ -19,6 +23,36 @@ This paper describes a classes and some helper functions provided by `chn-alias-
|
|
|
19
23
|
- <a href="#loadAliasFromFileSync">loadAliasFromFileSync</a>
|
|
20
24
|
- <a href="#saveAliasToFileSync">saveAliasToFileSync</a>
|
|
21
25
|
|
|
26
|
+
### Base type definitions
|
|
27
|
+
|
|
28
|
+
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
|
+
<a name="typedef+IChannelRecord"></a>
|
|
31
|
+
#### `IChannelRecord` - descriptor
|
|
32
|
+
|
|
33
|
+
This descriptor is an `object` that contains an info of a channel data.
|
|
34
|
+
|
|
35
|
+
| property name | value type | optional | description |
|
|
36
|
+
|:---|---|---:|:---|
|
|
37
|
+
| `id` | `string` | no | a channel ID |
|
|
38
|
+
| `alias` | `string` | no | a target ID for a channel |
|
|
39
|
+
| `name` | `any[]` | no | a list of a channel names |
|
|
40
|
+
| `status` | `string` | no | a channel status |
|
|
41
|
+
|
|
42
|
+
<a name="typedef+fsoDescr"></a>
|
|
43
|
+
#### `fsoDescr` - descriptor
|
|
44
|
+
|
|
45
|
+
This descriptor is an `object` that describes a status for an operation with some FS-object (*e.g. object such as a file*).
|
|
46
|
+
|
|
47
|
+
| property name | value type | optional | description |
|
|
48
|
+
|:---|---|---:|:---|
|
|
49
|
+
| `isERR` | `boolean` | no | a flag which indicates whether an error was happen |
|
|
50
|
+
| `errCode` | `number` | yes | an error code |
|
|
51
|
+
| `errEvent` | `string` | no | an error event identifier |
|
|
52
|
+
| `errMsg` | `string` | yes | an error message |
|
|
53
|
+
| `source` | `string` | yes | path to a file |
|
|
54
|
+
| `content` | `any` | yes | content |
|
|
55
|
+
|
|
22
56
|
## Module classes
|
|
23
57
|
|
|
24
58
|
<a name="TChnNameRecord"></a>
|
|
@@ -52,7 +86,7 @@ The class constructor creates a new instance of the class. It receives no argume
|
|
|
52
86
|
|
|
53
87
|
| value type | read only | description |
|
|
54
88
|
|---|---|:---|
|
|
55
|
-
| `
|
|
89
|
+
| `string[]` | no | defines a value of a name record |
|
|
56
90
|
|
|
57
91
|
#### class methods
|
|
58
92
|
|
|
@@ -103,7 +137,7 @@ The class constructor creates a new instance of the class. It receives no argume
|
|
|
103
137
|
|
|
104
138
|
| value type | read only | description |
|
|
105
139
|
|---|---|:---|
|
|
106
|
-
| `
|
|
140
|
+
| `TChnNameRecord[]` | yes | contains a list of a name records |
|
|
107
141
|
|
|
108
142
|
#### class methods
|
|
109
143
|
|
|
@@ -288,16 +322,12 @@ Sets a channel alias.
|
|
|
288
322
|
<a name="TChnAliasItem+addName"></a>
|
|
289
323
|
##### **addName(data)** => `boolean`
|
|
290
324
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
> **See**: [TChnNamesList.addName](#TChnNamesList+addName)
|
|
325
|
+
> \[!] NOTE: `[since v0.0.7]` deprecated. Use [`TChnNamesList.addItem`](#TChnNamesList+addItem) instead.
|
|
294
326
|
|
|
295
327
|
<a name="TChnAliasItem+loadNames"></a>
|
|
296
328
|
##### **loadNames(list, \[opt])** => `number`
|
|
297
329
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
> **See**: [TChnNamesList.loadNames](#TChnNamesList+loadNames)
|
|
330
|
+
> \[!] NOTE: `[since v0.0.7]` deprecated. Use [`TChnNamesList.loadItems`](#TChnNamesList+loadItems) instead.
|
|
301
331
|
|
|
302
332
|
<a name="TChnAliasItem+enable"></a>
|
|
303
333
|
##### **enable()** => `void`
|
|
@@ -333,7 +363,7 @@ Sets item status.
|
|
|
333
363
|
#### class methods (*special*)
|
|
334
364
|
|
|
335
365
|
<a name="TChnAliasItem+toJSON"></a>
|
|
336
|
-
##### **toJSON()**
|
|
366
|
+
##### **toJSON()** => `IChannelRecord`
|
|
337
367
|
|
|
338
368
|
A special method that provides an interface to an instance representation
|
|
339
369
|
for a `JSON.stringify()`.
|
|
340
370
|
|
|
@@ -346,7 +376,7 @@ Creates a new alias element.
|
|
|
346
376
|
|
|
347
377
|
| parameter name | value type | default value | description |
|
|
348
378
|
|:---|---|---:|:---|
|
|
349
|
-
| `obj` | `
|
|
379
|
+
| `obj` | `IChannelRecord` | --- | an initial data |
|
|
350
380
|
|
|
351
381
|
<a name="TChnAliasList"></a>
|
|
352
382
|
### **TChnAliasList**
|
|
@@ -423,7 +453,7 @@ Adds an alias element.
|
|
|
423
453
|
|
|
424
454
|
| parameter name | value type | default value | description |
|
|
425
455
|
|:---|---|---:|:---|
|
|
426
|
-
| `obj` | `
|
|
456
|
+
| `obj` | `IChannelRecord` | --- | an element to be added |
|
|
427
457
|
|
|
428
458
|
<a name="TChnAliasList+delItem"></a>
|
|
429
459
|
##### **delItem(value)** => `boolean`
|
|
@@ -441,7 +471,7 @@ Loads a list of a new alias elements.
|
|
|
441
471
|
|
|
442
472
|
| parameter name | value type | default value | description |
|
|
443
473
|
|:---|---|---:|:---|
|
|
444
|
-
| `list` | `
|
|
474
|
+
| `list` | `IChannelRecord[]` | --- | a list of an elements |
|
|
445
475
|
| `opt` | `boolean` | `true` | a flag that defines whether to clear the list before load a new one |
|
|
446
476
|
|
|
447
477
|
<a name="TChnAliasList+clear"></a>
|
|
@@ -474,7 +504,7 @@ Returns an array of a channel items picked up by a given function.
|
|
|
474
504
|
<a name="loadAliasFromFileSync"></a>
|
|
475
505
|
#### **loadAliasFromFileSync(src, [opt])** => `object`
|
|
476
506
|
|
|
477
|
-
Loads an alias from a file.
|
|
507
|
+
Loads an alias data from a file.
|
|
478
508
|
|
|
479
509
|
| parameter name | value type | default value | description |
|
|
480
510
|
|:---|---|---:|:---|
|
|
@@ -482,12 +512,12 @@ Loads an alias from a file.
|
|
|
482
512
|
| `opt` | `any` | --- | <*reserved*> |
|
|
483
513
|
|
|
484
514
|
<a name="saveAliasToFileSync"></a>
|
|
485
|
-
#### **saveAliasToFileSync(src, content, [opt])** => `
|
|
515
|
+
#### **saveAliasToFileSync(src, content, [opt])** => `fsoDescr`
|
|
486
516
|
|
|
487
|
-
Saves an alias to a file
|
|
517
|
+
Saves an alias data to a file.
|
|
488
518
|
|
|
489
519
|
| parameter name | value type | default value | description |
|
|
490
520
|
|:---|---|---:|:---|
|
|
491
521
|
| `src` | `string` | --- | a path to some file |
|
|
492
|
-
| `content` | `
|
|
522
|
+
| `content` | `object` or `object[]` | --- | a content to save |
|
|
493
523
|
| `opt` | `any` | --- | <*reserved*> |
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import type { fsoDescr } from '@cntwg/file-helper';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
TChnNameRecord, TChnNamesList,
|
|
5
|
+
TChnAliasItem, TChnAliasList,
|
|
6
|
+
type IChannelRecord,
|
|
7
|
+
} from './lib/chn-alias-list';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
loadAliasFromFileSync, saveAliasToFileSync,
|
|
11
|
+
type RVAL_loadaliasff,
|
|
12
|
+
} from './lib/file-helper-ext';
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
TChnNameRecord, TChnNamesList,
|
|
16
|
+
TChnAliasItem, TChnAliasList,
|
|
17
|
+
loadAliasFromFileSync, saveAliasToFileSync,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type {
|
|
21
|
+
fsoDescr,
|
|
22
|
+
IChannelRecord,
|
|
23
|
+
RVAL_loadaliasff,
|
|
24
|
+
};
|
package/lib/chn-alias-list.d.ts
CHANGED
|
@@ -1,292 +1,318 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
export type
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* @
|
|
106
|
-
* @
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
*
|
|
191
|
-
* @see
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Sets
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
*
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
*
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
*
|
|
257
|
-
*/
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
*
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
*
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Defines an object for storing a channel data
|
|
3
|
+
*/
|
|
4
|
+
export type IChannelRecord = {
|
|
5
|
+
/**
|
|
6
|
+
* - channel ID
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* - target ID
|
|
11
|
+
*/
|
|
12
|
+
alias: string;
|
|
13
|
+
/**
|
|
14
|
+
* - list of a channel names
|
|
15
|
+
*/
|
|
16
|
+
name: any[];
|
|
17
|
+
/**
|
|
18
|
+
* - channel status
|
|
19
|
+
*/
|
|
20
|
+
status: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A user defined procedure to process an array elements
|
|
24
|
+
*/
|
|
25
|
+
export type forEachProcEx = (item: any, index?: number, arr?: any[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* A user defined procedure to process an array elements
|
|
28
|
+
*/
|
|
29
|
+
export type cbArrECheck = (item: any, index?: number, arr?: any[]) => any;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @classdesc This class implements an interface of the name record
|
|
33
|
+
*/
|
|
34
|
+
export class TChnNameRecord {
|
|
35
|
+
/**
|
|
36
|
+
* Contains a language
|
|
37
|
+
*/
|
|
38
|
+
get lang(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Contains a value of the record
|
|
41
|
+
*/
|
|
42
|
+
get text(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Contains a value of the record
|
|
45
|
+
*/
|
|
46
|
+
get value(): string[];
|
|
47
|
+
set value(data: string[]);
|
|
48
|
+
/**
|
|
49
|
+
* Sets the record value
|
|
50
|
+
*/
|
|
51
|
+
setValue(data: any): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Returns value as a formated string
|
|
54
|
+
*/
|
|
55
|
+
toFormatString(opt: any): string;
|
|
56
|
+
/**
|
|
57
|
+
* Clears the record
|
|
58
|
+
*/
|
|
59
|
+
reset(): void;
|
|
60
|
+
#private;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @classdesc This class implements an interface of the name records list
|
|
65
|
+
*/
|
|
66
|
+
export class TChnNamesList {
|
|
67
|
+
/**
|
|
68
|
+
* Contains a quantity of a name records
|
|
69
|
+
*/
|
|
70
|
+
get count(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Contains a list of a name records
|
|
73
|
+
*/
|
|
74
|
+
get value(): TChnNameRecord[];
|
|
75
|
+
/**
|
|
76
|
+
* Returns a flag whether a list is empty or not
|
|
77
|
+
*/
|
|
78
|
+
isEmpty(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a flag whether a list has any members
|
|
81
|
+
*/
|
|
82
|
+
isNotEmpty(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Checks whether a given value is an index and fits an index range
|
|
85
|
+
* within the instance
|
|
86
|
+
*/
|
|
87
|
+
chkIndex(value: any): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Searches an index of a given name
|
|
90
|
+
*/
|
|
91
|
+
getIndex(value: string): number;
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated
|
|
94
|
+
* @see TChnNamesList.getItem
|
|
95
|
+
* @todo [from v0.0.5] make obsolete
|
|
96
|
+
*/
|
|
97
|
+
getName(value: any): TChnNameRecord;
|
|
98
|
+
/**
|
|
99
|
+
* Returns a name record
|
|
100
|
+
* @since 0.0.5
|
|
101
|
+
*/
|
|
102
|
+
getItem(value: number): TChnNameRecord | null;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated
|
|
105
|
+
* @see TChnNamesList.addItem
|
|
106
|
+
* @todo [from v0.0.5] make obsolete
|
|
107
|
+
*/
|
|
108
|
+
addName(data: any): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Adds a new name record to a list members
|
|
111
|
+
* @since 0.0.5
|
|
112
|
+
*/
|
|
113
|
+
addItem(data: any): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated
|
|
116
|
+
* @see TChnNamesList.delItem
|
|
117
|
+
* @todo [from v0.0.5] make obsolete
|
|
118
|
+
*/
|
|
119
|
+
delName(value: any): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Tries to delete a name record addressed by a given index
|
|
122
|
+
* @since 0.0.5
|
|
123
|
+
*/
|
|
124
|
+
delItem(value: number): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated
|
|
127
|
+
* @see TChnNamesList.loadItems
|
|
128
|
+
* @todo [from v0.0.5] make obsolete
|
|
129
|
+
*/
|
|
130
|
+
loadNames(...args: any[]): number;
|
|
131
|
+
/**
|
|
132
|
+
* Loads a new name records
|
|
133
|
+
* @since 0.0.5
|
|
134
|
+
*/
|
|
135
|
+
loadItems(list: any, opt?: boolean): number;
|
|
136
|
+
/**
|
|
137
|
+
* Removes all of the instance members
|
|
138
|
+
*/
|
|
139
|
+
clear(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Calls given function for each name record
|
|
142
|
+
*/
|
|
143
|
+
forEach(cb: forEachProcEx): void;
|
|
144
|
+
/**
|
|
145
|
+
* Returns an array of a name records picked up by a given function
|
|
146
|
+
*/
|
|
147
|
+
filter(cb: cbArrECheck): TChnNameRecord[];
|
|
148
|
+
[Symbol.iterator](): {
|
|
149
|
+
next: () => {
|
|
150
|
+
done: boolean;
|
|
151
|
+
value: TChnNameRecord | null;
|
|
152
|
+
} | {
|
|
153
|
+
done: boolean;
|
|
154
|
+
value?: undefined;
|
|
155
|
+
};
|
|
156
|
+
return(): {
|
|
157
|
+
done: boolean;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
#private;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @classdesc This class implements an interface of the channel item
|
|
165
|
+
*/
|
|
166
|
+
export class TChnAliasItem {
|
|
167
|
+
/**
|
|
168
|
+
* Creates a new alias element
|
|
169
|
+
*/
|
|
170
|
+
static create(obj: IChannelRecord): TChnAliasItem | null;
|
|
171
|
+
/**
|
|
172
|
+
* Contains a channel ID
|
|
173
|
+
*/
|
|
174
|
+
get id(): string;
|
|
175
|
+
set id(value: string);
|
|
176
|
+
/**
|
|
177
|
+
* Contains a channel alias
|
|
178
|
+
*/
|
|
179
|
+
get alias(): string;
|
|
180
|
+
set alias(value: string);
|
|
181
|
+
/**
|
|
182
|
+
* Contains a list of a name records
|
|
183
|
+
*/
|
|
184
|
+
get names(): TChnNamesList;
|
|
185
|
+
/**
|
|
186
|
+
* Contains an instance status
|
|
187
|
+
*/
|
|
188
|
+
get status(): string;
|
|
189
|
+
/**
|
|
190
|
+
* Sets a channel ID
|
|
191
|
+
* @see valueToIDString
|
|
192
|
+
*/
|
|
193
|
+
setID(value: string): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Sets a channel alias
|
|
196
|
+
* @see valueToIDString
|
|
197
|
+
*/
|
|
198
|
+
setAlias(value: string): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Returns a name record
|
|
201
|
+
* @deprecated
|
|
202
|
+
* @see TChnNamesList.getItem
|
|
203
|
+
* @todo [from v0.0.6] make obsolete
|
|
204
|
+
*/
|
|
205
|
+
getName(value: number): TChnNameRecord | null;
|
|
206
|
+
/**
|
|
207
|
+
* Adds a new name record
|
|
208
|
+
* @deprecated
|
|
209
|
+
* @see TChnNamesList.addItem
|
|
210
|
+
* @todo [from v0.0.7] deprecated. Use `TChnNamesList.addItem` instead.
|
|
211
|
+
*/
|
|
212
|
+
addName(data: any): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Loads a list of a new name records
|
|
215
|
+
* @deprecated
|
|
216
|
+
* @see TChnNamesList.loadItems
|
|
217
|
+
* @todo [from v0.0.7] deprecated. Use `TChnNamesList.loadItems` instead.
|
|
218
|
+
*/
|
|
219
|
+
loadNames(...args: [list: any, opt?: boolean]): number;
|
|
220
|
+
/**
|
|
221
|
+
* Sets item status to enabled
|
|
222
|
+
*/
|
|
223
|
+
enable(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Sets item status to disabled
|
|
226
|
+
*/
|
|
227
|
+
disable(): void;
|
|
228
|
+
/**
|
|
229
|
+
* Sets item status to active/running
|
|
230
|
+
*/
|
|
231
|
+
up(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Sets item status to inactive/stopped
|
|
234
|
+
*/
|
|
235
|
+
down(): void;
|
|
236
|
+
/**
|
|
237
|
+
* Sets item status
|
|
238
|
+
*/
|
|
239
|
+
setStatus(value: string): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Provides an interface to an instance representation for JSON.stringify()
|
|
242
|
+
*/
|
|
243
|
+
protected toJSON(): IChannelRecord;
|
|
244
|
+
#private;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @classdesc This class implements an interface of the channel items list
|
|
249
|
+
*/
|
|
250
|
+
export class TChnAliasList {
|
|
251
|
+
/**
|
|
252
|
+
* Contains a quantity of the elements
|
|
253
|
+
*/
|
|
254
|
+
get count(): number;
|
|
255
|
+
/**
|
|
256
|
+
* Returns a flag whether a list is empty or not
|
|
257
|
+
*/
|
|
258
|
+
isEmpty(): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Returns a flag whether a list has any members
|
|
261
|
+
*/
|
|
262
|
+
isNotEmpty(): boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Checks whether a given value is an index and fits an index range
|
|
265
|
+
* within the instance
|
|
266
|
+
*/
|
|
267
|
+
chkIndex(value: any): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Searches an index of an element by its ID
|
|
270
|
+
* @see valueToIDString
|
|
271
|
+
*/
|
|
272
|
+
searchIndexByID(value: string): number;
|
|
273
|
+
/**
|
|
274
|
+
* Returns an alias element by its index
|
|
275
|
+
*/
|
|
276
|
+
getItem(value: number): TChnAliasItem | null;
|
|
277
|
+
/**
|
|
278
|
+
* Returns an alias element by its ID
|
|
279
|
+
*/
|
|
280
|
+
getItemByID(value: string): TChnAliasItem | null;
|
|
281
|
+
/**
|
|
282
|
+
* Adds an alias element
|
|
283
|
+
*/
|
|
284
|
+
addItem(obj: IChannelRecord): number;
|
|
285
|
+
/**
|
|
286
|
+
* Tries to delete an element addressed by a given index
|
|
287
|
+
*/
|
|
288
|
+
delItem(value: number): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Loads a list of a new alias elements
|
|
291
|
+
*/
|
|
292
|
+
loadItems(list: IChannelRecord[], opt?: boolean): number;
|
|
293
|
+
/**
|
|
294
|
+
* Removes all of the instance members
|
|
295
|
+
*/
|
|
296
|
+
clear(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Calls given function for each alias element
|
|
299
|
+
*/
|
|
300
|
+
forEach(cb: forEachProcEx): void;
|
|
301
|
+
/**
|
|
302
|
+
* Returns an array of a name records picked up by a given function
|
|
303
|
+
*/
|
|
304
|
+
filter(cb: cbArrECheck): TChnAliasItem[];
|
|
305
|
+
[Symbol.iterator](): {
|
|
306
|
+
next: () => {
|
|
307
|
+
done: boolean;
|
|
308
|
+
value: TChnAliasItem | null;
|
|
309
|
+
} | {
|
|
310
|
+
done: boolean;
|
|
311
|
+
value?: undefined;
|
|
312
|
+
};
|
|
313
|
+
return(): {
|
|
314
|
+
done: boolean;
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
#private;
|
|
318
|
+
}
|
package/lib/chn-alias-list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.050-20260130]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -41,6 +41,15 @@ function convertLangTextValueToString(data, opt) {
|
|
|
41
41
|
* (* constant definitions *)
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Defines an object for storing a channel data
|
|
46
|
+
* @typedef {Object} IChannelRecord
|
|
47
|
+
* @property {string} id - channel ID
|
|
48
|
+
* @property {string} alias - target ID
|
|
49
|
+
* @property {any[]} name - list of a channel names
|
|
50
|
+
* @property {string} status - channel status
|
|
51
|
+
*/
|
|
52
|
+
|
|
44
53
|
/***
|
|
45
54
|
* (* function definitions *)
|
|
46
55
|
*/
|
|
@@ -490,6 +499,7 @@ class TChnAliasItem {
|
|
|
490
499
|
* @returns {?TChnNameRecord}
|
|
491
500
|
* @deprecated
|
|
492
501
|
* @see TChnNamesList.getItem
|
|
502
|
+
* @todo [from v0.0.6] make obsolete
|
|
493
503
|
*/
|
|
494
504
|
getName(value) {
|
|
495
505
|
return this.#_names.getItem(value);
|
|
@@ -499,7 +509,9 @@ class TChnAliasItem {
|
|
|
499
509
|
* Adds a new name record
|
|
500
510
|
* @param {any} data - a name record
|
|
501
511
|
* @returns {boolean}
|
|
512
|
+
* @deprecated
|
|
502
513
|
* @see TChnNamesList.addItem
|
|
514
|
+
* @todo [from v0.0.7] deprecated. Use `TChnNamesList.addItem` instead.
|
|
503
515
|
*/
|
|
504
516
|
addName(data) {
|
|
505
517
|
return this.#_names.addItem(data);
|
|
@@ -510,7 +522,9 @@ class TChnAliasItem {
|
|
|
510
522
|
* @param {array} list - a list of an elements
|
|
511
523
|
* @param {boolean} [opt=true] - defines whether to clear the list before load a new one
|
|
512
524
|
* @returns {number}
|
|
525
|
+
* @deprecated
|
|
513
526
|
* @see TChnNamesList.loadItems
|
|
527
|
+
* @todo [from v0.0.7] deprecated. Use `TChnNamesList.loadItems` instead.
|
|
514
528
|
*/
|
|
515
529
|
loadNames(...args) {
|
|
516
530
|
return this.#_names.loadItems(...args);
|
|
@@ -582,7 +596,7 @@ class TChnAliasItem {
|
|
|
582
596
|
|
|
583
597
|
/**
|
|
584
598
|
* Provides an interface to an instance representation for JSON.stringify()
|
|
585
|
-
* @returns {
|
|
599
|
+
* @returns {IChannelRecord}
|
|
586
600
|
* @protected
|
|
587
601
|
*/
|
|
588
602
|
toJSON() {
|
|
@@ -597,7 +611,7 @@ class TChnAliasItem {
|
|
|
597
611
|
|
|
598
612
|
/**
|
|
599
613
|
* Creates a new alias element
|
|
600
|
-
* @param {
|
|
614
|
+
* @param {IChannelRecord} obj - an init data
|
|
601
615
|
* @returns {?TChnAliasItem}
|
|
602
616
|
* @static
|
|
603
617
|
*/
|
|
@@ -726,7 +740,7 @@ class TChnAliasList {
|
|
|
726
740
|
|
|
727
741
|
/**
|
|
728
742
|
* Adds an alias element
|
|
729
|
-
* @param {
|
|
743
|
+
* @param {IChannelRecord} obj - an element to be added
|
|
730
744
|
* @returns {number}
|
|
731
745
|
*/
|
|
732
746
|
addItem(obj) {
|
|
@@ -734,7 +748,7 @@ class TChnAliasList {
|
|
|
734
748
|
let index = -1;
|
|
735
749
|
if (item !== null) {
|
|
736
750
|
const id = valueToIDString(item.id);
|
|
737
|
-
index = this.searchIndexByID(id);
|
|
751
|
+
if (id != null) index = this.searchIndexByID(id);
|
|
738
752
|
if (index === -1) {
|
|
739
753
|
index = this.count;
|
|
740
754
|
this.#_items.push(item);
|
|
@@ -758,7 +772,7 @@ class TChnAliasList {
|
|
|
758
772
|
|
|
759
773
|
/**
|
|
760
774
|
* Loads a list of a new alias elements
|
|
761
|
-
* @param {
|
|
775
|
+
* @param {IChannelRecord[]} list - a list of an elements
|
|
762
776
|
* @param {boolean} [opt=true] - defines whether to clear the list before load a new one
|
|
763
777
|
* @returns {number}
|
|
764
778
|
*/
|
package/lib/file-helper-ext.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A result of `loadAliasFromFile...`
|
|
3
|
-
*/
|
|
4
|
-
export type RVAL_loadaliasff = {
|
|
5
|
-
/**
|
|
6
|
-
* - ops description
|
|
7
|
-
*/
|
|
8
|
-
descr: fsoDescr;
|
|
9
|
-
/**
|
|
10
|
-
* - loaded content
|
|
11
|
-
*/
|
|
12
|
-
result: null | TChnAliasItem | TChnAliasList;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Loads an alias from a file
|
|
17
|
-
* @see {@link loadJSONFromFileSync} for details of an `opt` param
|
|
18
|
-
*/
|
|
19
|
-
export function loadAliasFromFileSync(src: string, opt?: any): RVAL_loadaliasff;
|
|
20
|
-
/**
|
|
21
|
-
* Saves an alias to a file
|
|
22
|
-
* @see {@link saveJSONToFileSync} for details of an `opt` param
|
|
23
|
-
*/
|
|
24
|
-
export function saveAliasToFileSync(src: string, content:
|
|
25
|
-
|
|
26
|
-
import type { fsoDescr } from
|
|
27
|
-
import { TChnAliasItem } from "./chn-alias-list";
|
|
28
|
-
import { TChnAliasList } from "./chn-alias-list";
|
|
1
|
+
/**
|
|
2
|
+
* A result of `loadAliasFromFile...`
|
|
3
|
+
*/
|
|
4
|
+
export type RVAL_loadaliasff = {
|
|
5
|
+
/**
|
|
6
|
+
* - ops description
|
|
7
|
+
*/
|
|
8
|
+
descr: fsoDescr;
|
|
9
|
+
/**
|
|
10
|
+
* - loaded content
|
|
11
|
+
*/
|
|
12
|
+
result: null | TChnAliasItem | TChnAliasList;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Loads an alias from a file
|
|
17
|
+
* @see {@link loadJSONFromFileSync} for details of an `opt` param
|
|
18
|
+
*/
|
|
19
|
+
export function loadAliasFromFileSync(src: string, opt?: any): RVAL_loadaliasff;
|
|
20
|
+
/**
|
|
21
|
+
* Saves an alias to a file
|
|
22
|
+
* @see {@link saveJSONToFileSync} for details of an `opt` param
|
|
23
|
+
*/
|
|
24
|
+
export function saveAliasToFileSync(src: string, content: object | object[], opt?: any): fsoDescr;
|
|
25
|
+
|
|
26
|
+
import type { fsoDescr } from "@cntwg/file-helper";
|
|
27
|
+
import { TChnAliasItem } from "./chn-alias-list";
|
|
28
|
+
import { TChnAliasList } from "./chn-alias-list";
|
package/lib/file-helper-ext.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.049-20260130]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
isArray,
|
|
6
|
+
isArray, isObject,
|
|
7
7
|
} = require('@ygracs/bsfoc-lib-js');
|
|
8
8
|
|
|
9
9
|
const {
|
|
@@ -63,17 +63,33 @@ function loadAliasFromFileSync(src, opt) {
|
|
|
63
63
|
* Saves an alias to a file
|
|
64
64
|
* @function saveAliasToFileSync
|
|
65
65
|
* @param {string} src - a path to some file
|
|
66
|
-
* @param {
|
|
66
|
+
* @param {(object|object[])} content - content
|
|
67
67
|
* @param {any} [opt] - <reserved>
|
|
68
68
|
* @returns {fsoDescr}
|
|
69
69
|
* @see {@link saveJSONToFileSync} for details of an `opt` param
|
|
70
70
|
*/
|
|
71
71
|
function saveAliasToFileSync(src, content, opt) {
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
/** @type {fsoDescr} */
|
|
73
|
+
let data = {
|
|
74
|
+
isERR: false,
|
|
75
|
+
errCode: 0,
|
|
76
|
+
errEvent: '',
|
|
77
|
+
errMsg: '',
|
|
78
|
+
source: '',
|
|
79
|
+
content: '',
|
|
80
|
+
};
|
|
81
|
+
if (isArray(content) || isObject(content)) {
|
|
82
|
+
//const obj = isArray(content) ? content : null;
|
|
83
|
+
//===
|
|
84
|
+
data = saveJSONToFileSync(src, content, opt);
|
|
85
|
+
} else {
|
|
86
|
+
if (content !== undefined) {
|
|
87
|
+
// // TODO: define `errCode` and `errMsg`
|
|
88
|
+
data.isERR = true;
|
|
89
|
+
data.errEvent = 'ERR_BAD_CONTENT';
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
return data;
|
|
77
93
|
};
|
|
78
94
|
|
|
79
95
|
/***
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ygracs/chn-alias-list",
|
|
3
|
-
"version": "0.0.7
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "A small library which provides some helper classes for EPG-tools",
|
|
5
5
|
"author": "ygracs <cs70th-om@rambler.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"main": "./index.js",
|
|
12
12
|
"types": "./index.d.ts",
|
|
13
13
|
"files": [
|
|
14
|
-
"doc
|
|
14
|
+
"doc/*.md",
|
|
15
15
|
"lib/chn-alias-list.js",
|
|
16
16
|
"lib/file-helper-ext.js",
|
|
17
17
|
"lib/*.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@ygracs/bsfoc-lib-js": "~0.3.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@ygracs/test-helper": "~0.0.
|
|
37
|
+
"@ygracs/test-helper": "~0.0.2-b",
|
|
38
38
|
"jest": "^30.2.0",
|
|
39
39
|
"jsdoc-to-markdown": "^9.1.3",
|
|
40
40
|
"minimist": "^1.2.8",
|