@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/index.js CHANGED
@@ -1,8 +1,18 @@
1
- // [v0.1.003-20260120]
1
+ // [v0.2.004-20260628]
2
2
 
3
3
  // === module init block ===
4
4
 
5
- const lib = require('./lib/chn-alias-list');
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 = lib.TChnNameRecord;
21
- module.exports.TChnNamesList = lib.TChnNamesList;
22
- module.exports.TChnAliasItem = lib.TChnAliasItem;
23
- module.exports.TChnAliasList = lib.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;
@@ -13,12 +13,13 @@ export type IChannelRecord = {
13
13
  /**
14
14
  * - list of a channel names
15
15
  */
16
- name: any[];
16
+ name: ILangTextPair[];
17
17
  /**
18
18
  * - channel status
19
19
  */
20
20
  status: string;
21
21
  };
22
+ export const IChannelRecord: IChannelRecord;
22
23
  /**
23
24
  * A user defined procedure to process an array elements
24
25
  */
@@ -27,139 +28,9 @@ export type forEachProcEx = (item: any, index?: number, arr?: any[]) => void;
27
28
  * A user defined procedure to process an array elements
28
29
  */
29
30
  export type cbArrECheck = (item: any, index?: number, arr?: any[]) => any;
31
+ import { ILangTextPair } from "./chn-names";
30
32
 
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
-
33
+ type loadItemsParams = Parameters<TChnNamesList["loadItems"]>;
163
34
  /**
164
35
  * @classdesc This class implements an interface of the channel item
165
36
  */
@@ -216,7 +87,7 @@ export class TChnAliasItem {
216
87
  * @see TChnNamesList.loadItems
217
88
  * @todo [from v0.0.7] deprecated. Use `TChnNamesList.loadItems` instead.
218
89
  */
219
- loadNames(...args: [list: any, opt?: boolean]): number;
90
+ loadNames(...args: loadItemsParams): number;
220
91
  /**
221
92
  * Sets item status to enabled
222
93
  */
@@ -263,8 +134,22 @@ export class TChnAliasList {
263
134
  /**
264
135
  * Checks whether a given value is an index and fits an index range
265
136
  * within the instance
137
+ * @deprecated
138
+ * @todo \[since v0.0.9] deprecated. Use {@link checkIndex} instead.
266
139
  */
267
140
  chkIndex(value: any): boolean;
141
+ /**
142
+ * Checks whether a given value is an index and fits an index range
143
+ * within the instance
144
+ * @since 0.0.9
145
+ */
146
+ checkIndex(value: any): boolean;
147
+ /**
148
+ * Returns an index in case a given value is a valid index value and not exceeds
149
+ * an index range within the instance. If failed a `-1` returned
150
+ * @since 0.0.9
151
+ */
152
+ tryIndex(value: any): number;
268
153
  /**
269
154
  * Searches an index of an element by its ID
270
155
  * @see valueToIDString
@@ -289,7 +174,7 @@ export class TChnAliasList {
289
174
  /**
290
175
  * Loads a list of a new alias elements
291
176
  */
292
- loadItems(list: IChannelRecord[], opt?: boolean): number;
177
+ loadItems(list: IChannelRecord[], opt?: boolean | ILoadListItemsOptions): number;
293
178
  /**
294
179
  * Removes all of the instance members
295
180
  */
@@ -316,3 +201,6 @@ export class TChnAliasList {
316
201
  };
317
202
  #private;
318
203
  }
204
+ import { TChnNamesList } from "./chn-names";
205
+ import { TChnNameRecord } from "./chn-names";
206
+ import { ILoadListItemsOptions } from "./chn-names";