@ygracs/xepg-lib-js 0.0.23 → 0.0.25

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,40 @@
1
+ #### *v0.0.25*
2
+
3
+ Pre-release version.
4
+
5
+ > - update `xepgdoc-lib.md`;
6
+ > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.0;
7
+ > - update dependency on `@ygracs/dtf-lib-js` module to v0.0.30;
8
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.2.4;
9
+ > - move some functions from `$lib/xepgdoc-lib.js` into new `$lib/xml-base.js` module;
10
+ > - add function: `readAsAttrValue`;
11
+ > - (`TXEpgHeaderContainer`) remove deprecated property: `Provider`;
12
+ > - (`TXEpgContentProvider`) remove deprecated properties: `Header`, `Provider`.
13
+
14
+ #### *v0.0.24*
15
+
16
+ Pre-release version.
17
+
18
+ > - update `xepgdoc-lib.md`;
19
+ > - update dependency on `@ygracs/dtf-lib-js` module to v0.0.29;
20
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.2.3;
21
+ > - (`TXEpgContentProvider`) add new properties: `schedules`;
22
+ > - (`TXEpgContentProvider`) deprecate properties: `SchedulesList`;
23
+ > - (`TXEpgContentProvider`) remove deprecated methods: `loadFromString`;
24
+ > - (`TXEpgHeaderContainer`) add new methods: `loadFromXMLString`;
25
+ > - (`TXEpgHeaderContainer`) deprecate methods: `setProviderInfo`;
26
+ > - (`TXEpgProviderContainer`) add new methods: `loadFromXMLString`;
27
+ > - (`TXEpgSchedulesList`) change constructor behavior on handling params (*see docs for details*);
28
+ > - (`TXEpgSchedulesList`) add new properties: `count`;
29
+ > - (`TXEpgSchedulesList`) deprecate properties: `schedQty`;
30
+ > - (`TXEpgSchedulesList`) add new methods: `isEmpty`, `isNotEmpty`;
31
+ > - (`TXEpgSchedulesList`) deprecate methods: `hasNoSchedules`, `hasSchedules`;
32
+ > - (`TXEpgSchedulesList`) remove deprecated methods: `chkScheduleIndex`;
33
+ > - (`TXEpgSchedulesList`) add iterator method;
34
+ > - (`TXEpgScheduleItem`) change constructor behavior on handling params (*see docs for details*);
35
+ > - (`TXEpgScheduleItem`) add new methods: `loadFromXMLString`;
36
+ > - other fixes.
37
+
1
38
  #### *v0.0.23*
2
39
 
3
40
  Pre-release version.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- |***rev.*:**|0.0.9|
1
+ |***rev.*:**|0.0.11|
2
2
  |:---|---:|
3
- |***date***:|2025-03-06|
3
+ |***date***:|2025-08-25|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -12,10 +12,17 @@ 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
+ + `readAsAttrValue`;
24
+ + `valueToElementID`;
25
+
19
26
  - classes:
20
27
 
21
28
  + `TXEpgScheduleItem`;
@@ -1,6 +1,6 @@
1
- |***rev.*:**|0.1.28|
1
+ |***rev.*:**|0.1.43|
2
2
  |:---|---:|
3
- |***date***:|2025-04-24|
3
+ |***date***:|2025-08-25|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -91,6 +91,17 @@ This function tries to convert a given `value` to the value of type which is sui
91
91
  |:---|---|---:|:---|
92
92
  | `value` | `any` | --- | some value to read |
93
93
 
94
+ <a name="readAsAttrValue"></a>
95
+ #### **readAsAttrValue(value)** => `string`
96
+
97
+ > since: \[`v0.0.25`]
98
+
99
+ This function tries to convert a given `value` to the value of type which is suitable for an XML-element's attribute. If failed a `null` is returned.
100
+
101
+ | parameter name | value type | default value | description |
102
+ |:---|---|---:|:---|
103
+ | `value` | `any` | --- | some value |
104
+
94
105
  <a name="valueToElementID"></a>
95
106
  #### **valueToElementID(value)**
96
107
 
@@ -115,14 +126,19 @@ This class provides a functionality for handle an EPG-schedule element.
115
126
 
116
127
  The class constructor creates a new instance of the class.
117
128
 
129
+ ##### syntax
130
+
131
+ `new TXEpgScheduleItem(object[, options[, extra]])`
132
+
118
133
  ##### constructor parameters
119
134
 
120
135
  The class constructor receives arguments listed below:
121
136
 
122
137
  | parameter name | value type | default value | description |
123
138
  |:---|---|---:|:---|
124
- |`object`|`object`|---|a host object|
125
- |`options`|`object`|---|an options settings|
139
+ | `object` | `object` | --- | a host object|
140
+ | `options` | `object` | --- | an options settings|
141
+ | `extra` | `object` | --- | \[*since: `v0.0.24`*] an extra options settings |
126
142
 
127
143
  #### class properties
128
144
 
@@ -232,6 +248,25 @@ This method tries to set a schedule description. If succeed `true` returned.
232
248
 
233
249
  This method saves an element content to a string in an XML-format.
234
250
 
251
+ #### class methods (*experimental*)
252
+
253
+ > 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.
254
+
255
+ <a name="TXEpgScheduleItem+loadFromXMLString"></a>
256
+ ##### **loadFromXMLString(str)** => `boolean`
257
+
258
+ > since: `v0.0.24`
259
+
260
+ This method loads an element content from a string given by a `str` parameter.
261
+
262
+ | parameter name | value type | default value | description |
263
+ |:---|---|---:|:---|
264
+ | `str` | `string` | --- | some content |
265
+
266
+ ###### *exceptions*
267
+
268
+ This methods throws `Error` if something goes wrong through a parsing process of a string.
269
+
235
270
  <a name="TXEpgSchedulesList"></a>
236
271
  ### **TXEpgSchedulesList**
237
272
 
@@ -241,20 +276,32 @@ This class provides a functionality for handle an EPG-schedules list.
241
276
 
242
277
  The class constructor creates a new instance of the class.
243
278
 
279
+ ##### syntax
280
+
281
+ `new TXEpgSchedulesList(object[, options[, extra]])`
282
+
244
283
  ##### constructor parameters
245
284
 
246
285
  The class constructor receives arguments listed below:
247
286
 
248
287
  | parameter name | value type | default value | description |
249
288
  |:---|---|---:|:---|
250
- |`object`|`array`|---|a host object|
251
- |`options`|`object`|---|an options settings|
289
+ | `object` | `array` | --- | a host object |
290
+ | `options` | `object` | --- | an options settings |
291
+ | `extra` | `object` | --- | \[*since: `v0.0.24`*] an extra options settings |
252
292
 
253
293
  #### class properties
254
294
 
255
295
  <a name="TXEpgSchedulesList+schedQty"></a>
256
296
  ##### **schedQty**
257
297
 
298
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`count` property](#TXEpgSchedulesList+count) instead.
299
+
300
+ <a name="TXEpgSchedulesList+count"></a>
301
+ ##### **count**
302
+
303
+ > since: \[`v0.0.24`]
304
+
258
305
  | property type | read only | description |
259
306
  |---|---|:---|
260
307
  | `number` | yes | contains a quantity of the elements the container holds |
@@ -278,16 +325,26 @@ The class constructor receives arguments listed below:
278
325
  <a name="TXEpgSchedulesList+hasNoSchedules"></a>
279
326
  ##### **hasNoSchedules()** => `boolean`
280
327
 
328
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isEmpty` method](#TXEpgSchedulesList+isEmpty) instead.
329
+
330
+ <a name="TXEpgSchedulesList+isEmpty"></a>
331
+ ##### **isEmpty()** => `boolean`
332
+
333
+ > since: `v0.0.24`
334
+
281
335
  This method returns `true` if a document contains no schedules.
282
336
 
283
337
  <a name="TXEpgSchedulesList+hasSchedules"></a>
284
338
  ##### **hasSchedules()** => `boolean`
285
339
 
286
- This method returns `true` if a document contains at least one schedule.
340
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isNotEmpty` method](#TXEpgSchedulesList+isNotEmpty) instead.
287
341
 
288
- ##### **chkScheduleIndex(value)** => `boolean`
342
+ <a name="TXEpgSchedulesList+isNotEmpty"></a>
343
+ ##### **isNotEmpty()** => `boolean`
289
344
 
290
- > WARNING: This method deprecated (*since `v0.0.20`*). Use `chkIndex` instead.
345
+ > since: `v0.0.24`
346
+
347
+ This method returns `true` if a document contains at least one schedule.
291
348
 
292
349
  <a name="TXEpgSchedulesList+chkIndex"></a>
293
350
  ##### **chkIndex(value)** => `boolean`
@@ -338,14 +395,18 @@ This class implements a structure that holds an information about a program prov
338
395
 
339
396
  The class constructor creates a new instance of the class.
340
397
 
398
+ ##### syntax
399
+
400
+ `new TXEpgProviderContainer(object[, options])`
401
+
341
402
  ##### constructor parameters
342
403
 
343
- The class constructor receives arguments listed below:
404
+ The class constructor receives an arguments listed below:
344
405
 
345
- |name|type|default value|description|
406
+ | parameter name | value type | default value | description |
346
407
  |:---|---|---:|:---|
347
- |`object`|`object`|---|a host object|
348
- |`options`|`object`|---|an option settings|
408
+ | `object` | `object` | --- | a host object |
409
+ | `options` | `object` | --- | an option settings |
349
410
 
350
411
  The `options` structure is listed below:
351
412
 
@@ -422,6 +483,25 @@ This method loads information about content provider.
422
483
 
423
484
  This method saves an element content to a string.
424
485
 
486
+ #### class methods (*experimental*)
487
+
488
+ > 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.
489
+
490
+ <a name="TXEpgProviderContainer+loadFromXMLString"></a>
491
+ ##### **loadFromXMLString(str)** => `boolean`
492
+
493
+ > since: `v0.0.24`
494
+
495
+ This method loads an element content from a string given by a `str` parameter.
496
+
497
+ | parameter name | value type | default value | description |
498
+ |:---|---|---:|:---|
499
+ | `str` | `string` | --- | some content |
500
+
501
+ ###### *exceptions*
502
+
503
+ This methods throws `Error` if something goes wrong through a parsing process of a string.
504
+
425
505
  #### class methods (*special*)
426
506
 
427
507
  ##### **init()**
@@ -601,11 +681,6 @@ The `options` structure is listed below:
601
681
  |---|---|:---|
602
682
  | `number` | no | defines a current TimeZone |
603
683
 
604
- <a name="TXEpgHeaderContainer+Provider"></a>
605
- ##### **Provider**
606
-
607
- > \[!] NOTE: `[since v0.0.22]` deprecated. Use [`provider` property](#TXEpgHeaderContainer+provider) instead.
608
-
609
684
  <a name="TXEpgHeaderContainer+provider"></a>
610
685
  ##### **provider**
611
686
 
@@ -667,7 +742,7 @@ An object contains the following fields:
667
742
  <a name="TXEpgHeaderContainer+setChannelInfo"></a>
668
743
  ##### **setChannelInfo(obj)** => `void`
669
744
 
670
- > \[!] WARNING: `[since v0.0.22]` deprecated.
745
+ > \[!] WARNING: `[since v0.0.22]` deprecated. Use [`TXEpgChannelContainer.setInfo()`](#TXEpgChannelContainer+setInfo) instead.
671
746
 
672
747
  This method fills a channel information with a given data.
673
748
 
@@ -701,6 +776,8 @@ This method returns an object which contains an information about document provi
701
776
 
702
777
  ##### **setProviderInfo(obj)**
703
778
 
779
+ > \[!] WARNING: `[since v0.0.24]` deprecated. Use [`TXEpgProviderContainer.setInfo()`](#TXEpgProviderContainer+setInfo) instead.
780
+
704
781
  <a name="TXEpgHeaderContainer+saveToXMLString"></a>
705
782
  ##### **saveToXMLString()** => `string`
706
783
 
@@ -708,6 +785,25 @@ This method returns an object which contains an information about document provi
708
785
 
709
786
  This method saves an element content to a string.
710
787
 
788
+ #### class methods (*experimental*)
789
+
790
+ > 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.
791
+
792
+ <a name="TXEpgHeaderContainer+loadFromXMLString"></a>
793
+ ##### **loadFromXMLString(str)** => `boolean`
794
+
795
+ > since: `v0.0.24`
796
+
797
+ This method loads an element content from a string given by a `str` parameter.
798
+
799
+ | parameter name | value type | default value | description |
800
+ |:---|---|---:|:---|
801
+ | `str` | `string` | --- | some content |
802
+
803
+ ###### *exceptions*
804
+
805
+ This methods throws `Error` if something goes wrong through a parsing process of a string.
806
+
711
807
  <a name="TXEpgContentProvider"></a>
712
808
  ### **TXEpgContentProvider**
713
809
 
@@ -732,11 +828,6 @@ The `options` structure is listed below:
732
828
 
733
829
  #### class properties
734
830
 
735
- <a name="TXEpgContentProvider+Header"></a>
736
- ##### **Header**
737
-
738
- > \[!] NOTE: `[since v0.0.22]` deprecated. Use [`header` property](#TXEpgContentProvider+header) instead.
739
-
740
831
  <a name="TXEpgContentProvider+header"></a>
741
832
  ##### **header**
742
833
 
@@ -746,11 +837,6 @@ The `options` structure is listed below:
746
837
  |---|---|:---|
747
838
  | `TXEpgHeaderContainer` | yes | returns a `TXEpgHeaderContainer` instance |
748
839
 
749
- <a name="TXEpgContentProvider+Provider"></a>
750
- ##### **Provider**
751
-
752
- > \[!] NOTE: `[since v0.0.22]` deprecated. Use [`provider` property](#TXEpgContentProvider+provider) instead.
753
-
754
840
  <a name="TXEpgContentProvider+provider"></a>
755
841
  ##### **provider**
756
842
 
@@ -770,6 +856,13 @@ The `options` structure is listed below:
770
856
  <a name="TXEpgContentProvider+SchedulesList"></a>
771
857
  ##### **SchedulesList**
772
858
 
859
+ > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`schedules` property](#TXEpgContentProvider+schedules) instead.
860
+
861
+ <a name="TXEpgContentProvider+schedules"></a>
862
+ ##### **schedules**
863
+
864
+ > since: `v0.0.24`
865
+
773
866
  | property type | read only | description |
774
867
  |---|---|:---|
775
868
  | `TXEpgSchedulesList` | yes | returns a `TXEpgSchedulesList` instance |
@@ -790,10 +883,6 @@ This method saves a document content into a file addressed by `src`.
790
883
  |:---|---|---:|:---|
791
884
  | `src` | `string` | --- | path to a file |
792
885
 
793
- ##### **loadFromString(xmlString, options)** => `boolean`
794
-
795
- > WARNING: This method deprecated (*since `v0.0.18`*). Use `loadFromXMLString` instead.
796
-
797
886
  <a name="TXEpgContentProvider+loadFromXMLString"></a>
798
887
  ##### **loadFromXMLString(str)** => `boolean`
799
888
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.0.010-20250228]
1
+ // [v0.1.014-20250825]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -6,7 +6,9 @@ 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
+ const xmlBase = require('./lib/xml-base');
10
+
11
+ // === module inner block ===
10
12
 
11
13
  // === module main block ===
12
14
 
@@ -20,8 +22,10 @@ module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
20
22
  module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
21
23
  module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
22
24
 
25
+ module.exports.readAsTagName = xmlBase.readAsTagName;
26
+ module.exports.readAsAttrName = xmlBase.readAsAttrName;
27
+ module.exports.readAsAttrValue = xmlBase.readAsAttrValue;
28
+ module.exports.valueToElementID = xmlBase.valueToElementID;
29
+
23
30
  // re-export stuff from `@ygracs/xobj-lib-js` module
24
31
  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) {