@ygracs/xepg-lib-js 0.0.22 → 0.0.24

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 CHANGED
@@ -1,3 +1,42 @@
1
+ #### *v0.0.24*
2
+
3
+ Pre-release version.
4
+
5
+ > - update `xepgdoc-lib.md`;
6
+ > - update dependency on `@ygracs/dtf-lib-js` module to v0.0.29;
7
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.2.3;
8
+ > - (`TXEpgContentProvider`) add new properties: `schedules`;
9
+ > - (`TXEpgContentProvider`) deprecate properties: `SchedulesList`;
10
+ > - (`TXEpgContentProvider`) remove deprecated methods: `loadFromString`;
11
+ > - (`TXEpgHeaderContainer`) add new methods: `loadFromXMLString`;
12
+ > - (`TXEpgHeaderContainer`) deprecate methods: `setProviderInfo`;
13
+ > - (`TXEpgProviderContainer`) add new methods: `loadFromXMLString`;
14
+ > - (`TXEpgSchedulesList`) change constructor behavior on handling params (*see docs for details*);
15
+ > - (`TXEpgSchedulesList`) add new properties: `count`;
16
+ > - (`TXEpgSchedulesList`) deprecate properties: `schedQty`;
17
+ > - (`TXEpgSchedulesList`) add new methods: `isEmpty`, `isNotEmpty`;
18
+ > - (`TXEpgSchedulesList`) deprecate methods: `hasNoSchedules`, `hasSchedules`;
19
+ > - (`TXEpgSchedulesList`) remove deprecated methods: `chkScheduleIndex`;
20
+ > - (`TXEpgSchedulesList`) add iterator method;
21
+ > - (`TXEpgScheduleItem`) change constructor behavior on handling params (*see docs for details*);
22
+ > - (`TXEpgScheduleItem`) add new methods: `loadFromXMLString`;
23
+ > - other fixes.
24
+
25
+ #### *v0.0.23*
26
+
27
+ Pre-release version.
28
+
29
+ > - update `xepgdoc-lib.md`;
30
+ > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.2.3;
31
+ > - update dependency on `@ygracs/dtf-lib-js` module to v0.0.28;
32
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.2.2;
33
+ > - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.0.5-b;
34
+ > - add dependency on `@cntwg/file-helper` module;
35
+ > - remove `$module/lib/file-helper.js`;
36
+ > - improve behavior for a getter of a `rating` property of a `TXEpgScheduleItem`-class;
37
+ > - add functions: readAsTagName, `readAsAttrName`, valueToElementID;
38
+ > - other fixes.
39
+
1
40
  #### *v0.0.22*
2
41
 
3
42
  Pre-release version.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- |***rev.*:**|0.0.9|
1
+ |***rev.*:**|0.0.10|
2
2
  |:---|---:|
3
- |***date***:|2025-03-06|
3
+ |***date***:|2025-07-30|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -12,10 +12,16 @@ This module provide a base functionality for handling an EPG-sources based on XE
12
12
 
13
13
  This module contains the following components:
14
14
 
15
- ### 1. a set of XEPG-document constants and components
15
+ ### 1. a set of XEPG-document constants, functions and components
16
16
 
17
17
  - constants:
18
18
 
19
+ - functions:
20
+
21
+ + `readAsTagName`;
22
+ + `readAsAttrName`;
23
+ + `valueToElementID`;
24
+
19
25
  - classes:
20
26
 
21
27
  + `TXEpgScheduleItem`;
@@ -1,12 +1,12 @@
1
- |***rev.*:**|0.1.26|
1
+ |***rev.*:**|0.1.40|
2
2
  |:---|---:|
3
- |***date***:|2025-03-06|
3
+ |***date***:|2025-07-30|
4
4
 
5
5
  ## Introduction
6
6
 
7
7
  This paper describes a constants and an object classes provided by `xepgdoc-lib.js` module.
8
8
 
9
- ### Base type definitions
9
+ ## Base type definitions
10
10
 
11
11
  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.
12
12
 
@@ -63,6 +63,45 @@ This descriptor is an `object` that describes a content provider.
63
63
 
64
64
  ## Module constants
65
65
 
66
+ ## Module functions
67
+
68
+ ### Experimental functions
69
+
70
+ > Note: Purpose of those functions will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
71
+
72
+ <a name="readAsTagName"></a>
73
+ #### **readAsTagName(value)** => `string`
74
+
75
+ > since: \[`v0.0.23`]
76
+
77
+ This function tries to convert a given `value` to the value of type which is suitable for an XML-element's tag name. If failed an empty string is returned.
78
+
79
+ | parameter name | value type | default value | description |
80
+ |:---|---|---:|:---|
81
+ | `value` | `any` | --- | some value to read |
82
+
83
+ <a name="readAsAttrName"></a>
84
+ #### **readAsAttrName(value)** => `string`
85
+
86
+ > since: \[`v0.0.23`]
87
+
88
+ This function tries to convert a given `value` to the value of type which is suitable for an XML-element's attribute name. If failed an empty string is returned.
89
+
90
+ | parameter name | value type | default value | description |
91
+ |:---|---|---:|:---|
92
+ | `value` | `any` | --- | some value to read |
93
+
94
+ <a name="valueToElementID"></a>
95
+ #### **valueToElementID(value)**
96
+
97
+ > since: \[`v0.0.23`]
98
+
99
+ This function tries to convert a given `value` to the value of a valid identifier which is suitable for an XML-element's ID-attribute. If failed an empty string is returned.
100
+
101
+ | parameter name | value type | default value | description |
102
+ |:---|---|---:|:---|
103
+ | `value` | `any` | --- | some value to read |
104
+
66
105
  ## Module classes
67
106
 
68
107
  <a name="TXEpgScheduleItem"></a>
@@ -76,14 +115,19 @@ This class provides a functionality for handle an EPG-schedule element.
76
115
 
77
116
  The class constructor creates a new instance of the class.
78
117
 
118
+ ##### syntax
119
+
120
+ `new TXEpgScheduleItem(object[, options[, extra]])`
121
+
79
122
  ##### constructor parameters
80
123
 
81
124
  The class constructor receives arguments listed below:
82
125
 
83
126
  | parameter name | value type | default value | description |
84
127
  |:---|---|---:|:---|
85
- |`object`|`object`|---|a host object|
86
- |`options`|`object`|---|an options settings|
128
+ | `object` | `object` | --- | a host object|
129
+ | `options` | `object` | --- | an options settings|
130
+ | `extra` | `object` | --- | \[*since: `v0.0.24`*] an extra options settings |
87
131
 
88
132
  #### class properties
89
133
 
@@ -193,6 +237,25 @@ This method tries to set a schedule description. If succeed `true` returned.
193
237
 
194
238
  This method saves an element content to a string in an XML-format.
195
239
 
240
+ #### class methods (*experimental*)
241
+
242
+ > Note: Purpose of those methods will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
243
+
244
+ <a name="TXEpgScheduleItem+loadFromXMLString"></a>
245
+ ##### **loadFromXMLString(str)** => `boolean`
246
+
247
+ > since: `v0.0.24`
248
+
249
+ This method loads an element content from a string given by a `str` parameter.
250
+
251
+ | parameter name | value type | default value | description |
252
+ |:---|---|---:|:---|
253
+ | `str` | `string` | --- | some content |
254
+
255
+ ###### *exceptions*
256
+
257
+ This methods throws `Error` if something goes wrong through a parsing process of a string.
258
+
196
259
  <a name="TXEpgSchedulesList"></a>
197
260
  ### **TXEpgSchedulesList**
198
261
 
@@ -202,20 +265,32 @@ This class provides a functionality for handle an EPG-schedules list.
202
265
 
203
266
  The class constructor creates a new instance of the class.
204
267
 
268
+ ##### syntax
269
+
270
+ `new TXEpgSchedulesList(object[, options[, extra]])`
271
+
205
272
  ##### constructor parameters
206
273
 
207
274
  The class constructor receives arguments listed below:
208
275
 
209
276
  | parameter name | value type | default value | description |
210
277
  |:---|---|---:|:---|
211
- |`object`|`array`|---|a host object|
212
- |`options`|`object`|---|an options settings|
278
+ | `object` | `array` | --- | a host object |
279
+ | `options` | `object` | --- | an options settings |
280
+ | `extra` | `object` | --- | \[*since: `v0.0.24`*] an extra options settings |
213
281
 
214
282
  #### class properties
215
283
 
216
284
  <a name="TXEpgSchedulesList+schedQty"></a>
217
285
  ##### **schedQty**
218
286
 
287
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`count` property](#TXEpgSchedulesList+count) instead.
288
+
289
+ <a name="TXEpgSchedulesList+count"></a>
290
+ ##### **count**
291
+
292
+ > since: \[`v0.0.24`]
293
+
219
294
  | property type | read only | description |
220
295
  |---|---|:---|
221
296
  | `number` | yes | contains a quantity of the elements the container holds |
@@ -239,16 +314,26 @@ The class constructor receives arguments listed below:
239
314
  <a name="TXEpgSchedulesList+hasNoSchedules"></a>
240
315
  ##### **hasNoSchedules()** => `boolean`
241
316
 
317
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isEmpty` method](#TXEpgSchedulesList+isEmpty) instead.
318
+
319
+ <a name="TXEpgSchedulesList+isEmpty"></a>
320
+ ##### **isEmpty()** => `boolean`
321
+
322
+ > since: `v0.0.24`
323
+
242
324
  This method returns `true` if a document contains no schedules.
243
325
 
244
326
  <a name="TXEpgSchedulesList+hasSchedules"></a>
245
327
  ##### **hasSchedules()** => `boolean`
246
328
 
247
- This method returns `true` if a document contains at least one schedule.
329
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isNotEmpty` method](#TXEpgSchedulesList+isNotEmpty) instead.
330
+
331
+ <a name="TXEpgSchedulesList+isNotEmpty"></a>
332
+ ##### **isNotEmpty()** => `boolean`
248
333
 
249
- ##### **chkScheduleIndex(value)** => `boolean`
334
+ > since: `v0.0.24`
250
335
 
251
- > WARNING: This method deprecated (*since `v0.0.20`*). Use `chkIndex` instead.
336
+ This method returns `true` if a document contains at least one schedule.
252
337
 
253
338
  <a name="TXEpgSchedulesList+chkIndex"></a>
254
339
  ##### **chkIndex(value)** => `boolean`
@@ -299,14 +384,18 @@ This class implements a structure that holds an information about a program prov
299
384
 
300
385
  The class constructor creates a new instance of the class.
301
386
 
387
+ ##### syntax
388
+
389
+ `new TXEpgProviderContainer(object[, options])`
390
+
302
391
  ##### constructor parameters
303
392
 
304
- The class constructor receives arguments listed below:
393
+ The class constructor receives an arguments listed below:
305
394
 
306
- |name|type|default value|description|
395
+ | parameter name | value type | default value | description |
307
396
  |:---|---|---:|:---|
308
- |`object`|`object`|---|a host object|
309
- |`options`|`object`|---|an option settings|
397
+ | `object` | `object` | --- | a host object |
398
+ | `options` | `object` | --- | an option settings |
310
399
 
311
400
  The `options` structure is listed below:
312
401
 
@@ -383,6 +472,25 @@ This method loads information about content provider.
383
472
 
384
473
  This method saves an element content to a string.
385
474
 
475
+ #### class methods (*experimental*)
476
+
477
+ > Note: Purpose of those methods will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
478
+
479
+ <a name="TXEpgProviderContainer+loadFromXMLString"></a>
480
+ ##### **loadFromXMLString(str)** => `boolean`
481
+
482
+ > since: `v0.0.24`
483
+
484
+ This method loads an element content from a string given by a `str` parameter.
485
+
486
+ | parameter name | value type | default value | description |
487
+ |:---|---|---:|:---|
488
+ | `str` | `string` | --- | some content |
489
+
490
+ ###### *exceptions*
491
+
492
+ This methods throws `Error` if something goes wrong through a parsing process of a string.
493
+
386
494
  #### class methods (*special*)
387
495
 
388
496
  ##### **init()**
@@ -565,7 +673,7 @@ The `options` structure is listed below:
565
673
  <a name="TXEpgHeaderContainer+Provider"></a>
566
674
  ##### **Provider**
567
675
 
568
- > \[!] NOTE: `[since v0.0.22]` deprecated. Use (`provider` property)[#TXEpgHeaderContainer+provider] instead.
676
+ > \[!] NOTE: `[since v0.0.22]` deprecated. Use [`provider` property](#TXEpgHeaderContainer+provider) instead.
569
677
 
570
678
  <a name="TXEpgHeaderContainer+provider"></a>
571
679
  ##### **provider**
@@ -628,7 +736,7 @@ An object contains the following fields:
628
736
  <a name="TXEpgHeaderContainer+setChannelInfo"></a>
629
737
  ##### **setChannelInfo(obj)** => `void`
630
738
 
631
- > \[!] WARNING: `[since v0.0.22]` deprecated.
739
+ > \[!] WARNING: `[since v0.0.22]` deprecated. Use [`TXEpgChannelContainer.setInfo()`](#TXEpgChannelContainer+setInfo) instead.
632
740
 
633
741
  This method fills a channel information with a given data.
634
742
 
@@ -662,6 +770,8 @@ This method returns an object which contains an information about document provi
662
770
 
663
771
  ##### **setProviderInfo(obj)**
664
772
 
773
+ > \[!] WARNING: `[since v0.0.24]` deprecated. Use [`TXEpgProviderContainer.setInfo()`](#TXEpgProviderContainer+setInfo) instead.
774
+
665
775
  <a name="TXEpgHeaderContainer+saveToXMLString"></a>
666
776
  ##### **saveToXMLString()** => `string`
667
777
 
@@ -669,6 +779,25 @@ This method returns an object which contains an information about document provi
669
779
 
670
780
  This method saves an element content to a string.
671
781
 
782
+ #### class methods (*experimental*)
783
+
784
+ > Note: Purpose of those methods will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
785
+
786
+ <a name="TXEpgHeaderContainer+loadFromXMLString"></a>
787
+ ##### **loadFromXMLString(str)** => `boolean`
788
+
789
+ > since: `v0.0.24`
790
+
791
+ This method loads an element content from a string given by a `str` parameter.
792
+
793
+ | parameter name | value type | default value | description |
794
+ |:---|---|---:|:---|
795
+ | `str` | `string` | --- | some content |
796
+
797
+ ###### *exceptions*
798
+
799
+ This methods throws `Error` if something goes wrong through a parsing process of a string.
800
+
672
801
  <a name="TXEpgContentProvider"></a>
673
802
  ### **TXEpgContentProvider**
674
803
 
@@ -696,7 +825,7 @@ The `options` structure is listed below:
696
825
  <a name="TXEpgContentProvider+Header"></a>
697
826
  ##### **Header**
698
827
 
699
- > \[!] NOTE: `[since v0.0.22]` deprecated. Use (`header` property)[#TXEpgContentProvider+header] instead.
828
+ > \[!] NOTE: `[since v0.0.22]` deprecated. Use [`header` property](#TXEpgContentProvider+header) instead.
700
829
 
701
830
  <a name="TXEpgContentProvider+header"></a>
702
831
  ##### **header**
@@ -710,7 +839,7 @@ The `options` structure is listed below:
710
839
  <a name="TXEpgContentProvider+Provider"></a>
711
840
  ##### **Provider**
712
841
 
713
- > \[!] NOTE: `[since v0.0.22]` deprecated. Use (`provider` property)[#TXEpgContentProvider+provider] instead.
842
+ > \[!] NOTE: `[since v0.0.22]` deprecated. Use [`provider` property](#TXEpgContentProvider+provider) instead.
714
843
 
715
844
  <a name="TXEpgContentProvider+provider"></a>
716
845
  ##### **provider**
@@ -731,6 +860,13 @@ The `options` structure is listed below:
731
860
  <a name="TXEpgContentProvider+SchedulesList"></a>
732
861
  ##### **SchedulesList**
733
862
 
863
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`schedules` property](#TXEpgContentProvider+schedules) instead.
864
+
865
+ <a name="TXEpgContentProvider+schedules"></a>
866
+ ##### **schedules**
867
+
868
+ > since: `v0.0.24`
869
+
734
870
  | property type | read only | description |
735
871
  |---|---|:---|
736
872
  | `TXEpgSchedulesList` | yes | returns a `TXEpgSchedulesList` instance |
@@ -751,10 +887,6 @@ This method saves a document content into a file addressed by `src`.
751
887
  |:---|---|---:|:---|
752
888
  | `src` | `string` | --- | path to a file |
753
889
 
754
- ##### **loadFromString(xmlString, options)** => `boolean`
755
-
756
- > WARNING: This method deprecated (*since `v0.0.18`*). Use `loadFromXMLString` instead.
757
-
758
890
  <a name="TXEpgContentProvider+loadFromXMLString"></a>
759
891
  ##### **loadFromXMLString(str)** => `boolean`
760
892
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.0.010-20250228]
1
+ // [v0.1.011-20250727]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -6,7 +6,7 @@ const xepgdoc = require('./lib/xepgdoc-lib.js');
6
6
 
7
7
  const xObj = require('@ygracs/xobj-lib-js');
8
8
 
9
- // === module extra block (helper functions) ===
9
+ // === module inner block ===
10
10
 
11
11
  // === module main block ===
12
12
 
@@ -20,8 +20,9 @@ module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
20
20
  module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
21
21
  module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
22
22
 
23
+ module.exports.readAsTagName = xepgdoc.readAsTagName;
24
+ module.exports.readAsAttrName = xepgdoc.readAsAttrName;
25
+ module.exports.valueToElementID = xepgdoc.valueToElementID;
26
+
23
27
  // re-export stuff from `@ygracs/xobj-lib-js` module
24
28
  module.exports.TXmlContentParseOptions = xObj.TXmlContentParseOptions;
25
-
26
- /**/// will deprecate
27
- module.exports.TXepgDTSProvider = xepgdoc.TXepgDTSProvider;
package/lib/dts-helper.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.047-20250225]
1
+ // [v0.1.048-20250727]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -30,10 +30,10 @@ const def_dts_param = [
30
30
  */
31
31
 
32
32
  /**
33
+ * Checks if a given value is a valid dtstype ID
33
34
  * @function chkDTSysID
34
35
  * @param {(number|string)} value - value to verify
35
36
  * @returns {boolean}
36
- * @description Checs if a given value is a valid dtstype ID
37
37
  */
38
38
  function chkDTSysID(value) {
39
39
  const _value = valueToIndex(value);
@@ -41,10 +41,10 @@ function chkDTSysID(value) {
41
41
  };
42
42
 
43
43
  /**
44
+ * Returns a dtstype name by a given dtstype ID
44
45
  * @function getDTSysName
45
46
  * @param {(number|string)} value - DTS-type identifier
46
47
  * @returns {string}
47
- * @description Returns a dtstype name by a given dtstype ID
48
48
  */
49
49
  function getDTSysName(value) {
50
50
  let result = 'undefined';
@@ -55,17 +55,17 @@ function getDTSysName(value) {
55
55
  };
56
56
 
57
57
  /**
58
+ * A 'DTS'-type descriptor
58
59
  * @typedef {Object} DTSysDescr
59
60
  * @property {number} index - dtstype ID
60
61
  * @property {string} name - dtstype name
61
- * @description A DTS-type descriptor
62
62
  */
63
63
 
64
64
  /**
65
+ * Returns a dtstype description for a given dtstype ID
65
66
  * @function getDTSysDescr
66
67
  * @param {(number|string)} value - DTS-type identifier
67
68
  * @returns {DTSysDescr}
68
- * @description Returns a dtstype description for a given dtstype ID
69
69
  */
70
70
  function getDTSysDescr(value) {
71
71
  let index = valueToIndex(value);
@@ -84,12 +84,12 @@ function getDTSysDescr(value) {
84
84
  };
85
85
 
86
86
  /**
87
+ * Tries to convert a given string to timestamp
87
88
  * @function convStringToDTValue
88
89
  * @param {string} value - some value
89
90
  * @param {(number|string)} [dts_id=0] - DTS-type identifier
90
91
  * @param {(number|string)} [tz] - <*reserved*>
91
92
  * @returns {number}
92
- * @description Tries to convert a given string to timestamp
93
93
  * @todo check TZ
94
94
  */
95
95
  function convStringToDTValue(value, dts_id = 0, tz) {
@@ -150,12 +150,12 @@ function convStringToDTValue(value, dts_id = 0, tz) {
150
150
  };
151
151
 
152
152
  /**
153
+ * Tries to convert a given value to its string representation
153
154
  * @function convDTValueToString
154
155
  * @param {(number|string|Date)} value - some value
155
156
  * @param {(number|string)} [dts_id=0] - DTS-type identifier
156
157
  * @param {(number|string)} [tz] - <*reserved*>
157
158
  * @returns {string}
158
- * @description Tries to convert a given value to its string representation
159
159
  * @todo check TZ
160
160
  */
161
161
  function convDTValueToString(value, dts_id, tz) {