ilib-tools-common 1.4.0 → 1.5.0

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/README.md CHANGED
@@ -21,6 +21,10 @@ limitations under the License.
21
21
 
22
22
  ## Release Notes
23
23
 
24
+ ### v1.5.0
25
+
26
+ - Added getVariant method to the TranslationUnit class
27
+
24
28
  ### v1.4.0
25
29
 
26
30
  - Added TranslationUnit and TranslationVariant classes
@@ -3613,7 +3613,7 @@ stage of life of this resource. Currently, it can be one of "new",
3613
3613
  <br class="clear">
3614
3614
 
3615
3615
  <footer>
3616
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
3616
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
3617
3617
  </footer>
3618
3618
 
3619
3619
  <script>prettyPrint();</script>
@@ -512,7 +512,7 @@ export default Resource;
512
512
  <br class="clear">
513
513
 
514
514
  <footer>
515
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
515
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
516
516
  </footer>
517
517
 
518
518
  <script>prettyPrint();</script>
@@ -6147,7 +6147,7 @@ parameters.</li></ul></dd>
6147
6147
  <br class="clear">
6148
6148
 
6149
6149
  <footer>
6150
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
6150
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
6151
6151
  </footer>
6152
6152
 
6153
6153
  <script>prettyPrint();</script>
@@ -461,7 +461,7 @@ export default ResourceArray;
461
461
  <br class="clear">
462
462
 
463
463
  <footer>
464
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
464
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
465
465
  </footer>
466
466
 
467
467
  <script>prettyPrint();</script>
@@ -6502,7 +6502,7 @@ parameters.</li></ul></dd>
6502
6502
  <br class="clear">
6503
6503
 
6504
6504
  <footer>
6505
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
6505
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
6506
6506
  </footer>
6507
6507
 
6508
6508
  <script>prettyPrint();</script>
@@ -460,7 +460,7 @@ export default ResourcePlural;
460
460
  <br class="clear">
461
461
 
462
462
  <footer>
463
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
463
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
464
464
  </footer>
465
465
 
466
466
  <script>prettyPrint();</script>
@@ -5554,7 +5554,7 @@ parameters.</li></ul></dd>
5554
5554
  <br class="clear">
5555
5555
 
5556
5556
  <footer>
5557
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
5557
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
5558
5558
  </footer>
5559
5559
 
5560
5560
  <script>prettyPrint();</script>
@@ -287,7 +287,7 @@ export default ResourceString;
287
287
  <br class="clear">
288
288
 
289
289
  <footer>
290
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
290
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
291
291
  </footer>
292
292
 
293
293
  <script>prettyPrint();</script>
@@ -259,7 +259,7 @@ initialize the file, or undefined for a new empty file</td>
259
259
  <br class="clear">
260
260
 
261
261
  <footer>
262
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
262
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
263
263
  </footer>
264
264
 
265
265
  <script>prettyPrint();</script>
@@ -501,7 +501,7 @@ export default ResourceXliff;
501
501
  <br class="clear">
502
502
 
503
503
  <footer>
504
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
504
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
505
505
  </footer>
506
506
 
507
507
  <script>prettyPrint();</script>
@@ -2678,7 +2678,7 @@ the dirty flag to true again.</li></ul></dd>
2678
2678
  <br class="clear">
2679
2679
 
2680
2680
  <footer>
2681
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
2681
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
2682
2682
  </footer>
2683
2683
 
2684
2684
  <script>prettyPrint();</script>
@@ -458,7 +458,7 @@ export default TranslationSet;
458
458
  <br class="clear">
459
459
 
460
460
  <footer>
461
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
461
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
462
462
  </footer>
463
463
 
464
464
  <script>prettyPrint();</script>
@@ -273,7 +273,7 @@ source locale and no target text, but different target locales.</li></ul></dd>
273
273
 
274
274
  <dt class="tag-source">Source:</dt>
275
275
  <dd class="tag-source"><ul class="dummy"><li>
276
- <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line169">line 169</a>
276
+ <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line175">line 175</a>
277
277
  </li></ul></dd>
278
278
 
279
279
 
@@ -411,7 +411,7 @@ string.</li></ul></dd>
411
411
 
412
412
  <dt class="tag-source">Source:</dt>
413
413
  <dd class="tag-source"><ul class="dummy"><li>
414
- <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line135">line 135</a>
414
+ <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line141">line 141</a>
415
415
  </li></ul></dd>
416
416
 
417
417
 
@@ -549,7 +549,7 @@ variant.</li></ul></dd>
549
549
 
550
550
  <dt class="tag-source">Source:</dt>
551
551
  <dd class="tag-source"><ul class="dummy"><li>
552
- <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line151">line 151</a>
552
+ <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line157">line 157</a>
553
553
  </li></ul></dd>
554
554
 
555
555
 
@@ -792,7 +792,7 @@ variant.</li></ul></dd>
792
792
 
793
793
  <dt class="tag-source">Source:</dt>
794
794
  <dd class="tag-source"><ul class="dummy"><li>
795
- <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line161">line 161</a>
795
+ <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line167">line 167</a>
796
796
  </li></ul></dd>
797
797
 
798
798
 
@@ -884,7 +884,7 @@ variant.</li></ul></dd>
884
884
 
885
885
 
886
886
 
887
- <h4 class="name" id="getVariants"><span class="type-signature"></span>getVariants<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="TranslationVariant.html">TranslationVariant</a>>}</span></h4>
887
+ <h4 class="name" id="getVariants"><span class="type-signature"></span>getVariants<span class="signature">(locale)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="TranslationVariant.html">TranslationVariant</a>>}</span></h4>
888
888
 
889
889
 
890
890
 
@@ -894,13 +894,14 @@ variant.</li></ul></dd>
894
894
  <dl class="details">
895
895
 
896
896
  <dt class="tag-description">Description:</dt>
897
- <dd class="tag-description"><ul class="dummy"><li>Return the list of variants for this translation unit.</li></ul></dd>
897
+ <dd class="tag-description"><ul class="dummy"><li>Return the list of variants for this translation unit. If the locale
898
+ parameter is specified, only return the variants for the given locale.</li></ul></dd>
898
899
 
899
900
 
900
901
 
901
902
  <dt class="tag-source">Source:</dt>
902
903
  <dd class="tag-source"><ul class="dummy"><li>
903
- <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line123">line 123</a>
904
+ <a href="TranslationUnit.js.html">TranslationUnit.js</a>, <a href="TranslationUnit.js.html#line126">line 126</a>
904
905
  </li></ul></dd>
905
906
 
906
907
 
@@ -947,6 +948,59 @@ variant.</li></ul></dd>
947
948
 
948
949
 
949
950
 
951
+ <h5 class="h5-parameters">Parameters:</h5>
952
+
953
+
954
+ <table class="params">
955
+ <thead>
956
+ <tr>
957
+
958
+ <th>Name</th>
959
+
960
+
961
+ <th>Type</th>
962
+
963
+
964
+
965
+
966
+
967
+ <th class="last">Description</th>
968
+ </tr>
969
+ </thead>
970
+
971
+ <tbody>
972
+
973
+
974
+ <tr>
975
+
976
+ <td class="name"><code>locale</code></td>
977
+
978
+
979
+ <td class="type">
980
+
981
+
982
+ <span class="param-type">String</span>
983
+ |
984
+
985
+ <span class="param-type">undefined</span>
986
+
987
+
988
+
989
+
990
+ </td>
991
+
992
+
993
+
994
+
995
+
996
+ <td class="description last">the locale to find</td>
997
+ </tr>
998
+
999
+
1000
+ </tbody>
1001
+ </table>
1002
+
1003
+
950
1004
 
951
1005
 
952
1006
 
@@ -1119,7 +1173,7 @@ the unit.</li></ul></dd>
1119
1173
  <br class="clear">
1120
1174
 
1121
1175
  <footer>
1122
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1176
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1123
1177
  </footer>
1124
1178
 
1125
1179
  <script>prettyPrint();</script>
@@ -163,11 +163,17 @@ class TranslationUnit {
163
163
  }
164
164
 
165
165
  /**
166
- * Return the list of variants for this translation unit.
166
+ * Return the list of variants for this translation unit. If the locale
167
+ * parameter is specified, only return the variants for the given locale.
168
+ *
169
+ * @param {String|undefined} locale the locale to find
167
170
  * @returns {Array.&lt;TranslationVariant>} the variants for
168
171
  * this translation unit
169
172
  */
170
- getVariants() {
173
+ getVariants(locale) {
174
+ if (locale) {
175
+ return this.variants.filter(variant => (variant.locale === locale));
176
+ }
171
177
  return this.variants;
172
178
  }
173
179
 
@@ -236,7 +242,7 @@ export default TranslationUnit;</code></pre>
236
242
  <br class="clear">
237
243
 
238
244
  <footer>
239
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
245
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
240
246
  </footer>
241
247
 
242
248
  <script>prettyPrint();</script>
@@ -350,7 +350,7 @@ hash key is calculated from the source string and locale.</li></ul></dd>
350
350
  <br class="clear">
351
351
 
352
352
  <footer>
353
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
353
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
354
354
  </footer>
355
355
 
356
356
  <script>prettyPrint();</script>
@@ -109,7 +109,7 @@ export default TranslationVariant;</code></pre>
109
109
  <br class="clear">
110
110
 
111
111
  <footer>
112
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
112
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
113
113
  </footer>
114
114
 
115
115
  <script>prettyPrint();</script>
package/docs/global.html CHANGED
@@ -1366,7 +1366,7 @@ primitive processed by the visitor function
1366
1366
  <br class="clear">
1367
1367
 
1368
1368
  <footer>
1369
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1369
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1370
1370
  </footer>
1371
1371
 
1372
1372
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
@@ -64,8 +64,8 @@
64
64
  * limitations under the License.
65
65
  */
66
66
 
67
- import fs from 'node:fs';
68
- import path from 'node:path';
67
+ import fs from 'fs';
68
+ import path from 'path';
69
69
  import Locale from 'ilib-locale';
70
70
 
71
71
  import { isAlnum, isIdeo } from 'ilib-ctype';
@@ -463,7 +463,7 @@ export function hashKey(source) {
463
463
  <br class="clear">
464
464
 
465
465
  <footer>
466
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Jan 24 2023 22:21:49 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
466
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.0</a> on Tue Mar 21 2023 10:31:35 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
467
467
  </footer>
468
468
 
469
469
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilib-tools-common",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "module": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -65,7 +65,8 @@
65
65
  "jsdoc": "^4.0.0",
66
66
  "jsdoc-to-markdown": "^8.0.0",
67
67
  "nodeunit": "^0.11.3",
68
- "npm-run-all": "^4.1.5"
68
+ "npm-run-all": "^4.1.5",
69
+ "semver": "^7.3.8"
69
70
  },
70
71
  "dependencies": {
71
72
  "@log4js-node/log4js-api": "^1.0.2",
@@ -116,11 +116,17 @@ class TranslationUnit {
116
116
  }
117
117
 
118
118
  /**
119
- * Return the list of variants for this translation unit.
119
+ * Return the list of variants for this translation unit. If the locale
120
+ * parameter is specified, only return the variants for the given locale.
121
+ *
122
+ * @param {String|undefined} locale the locale to find
120
123
  * @returns {Array.<TranslationVariant>} the variants for
121
124
  * this translation unit
122
125
  */
123
- getVariants() {
126
+ getVariants(locale) {
127
+ if (locale) {
128
+ return this.variants.filter(variant => (variant.locale === locale));
129
+ }
124
130
  return this.variants;
125
131
  }
126
132
 
package/src/utils.js CHANGED
@@ -17,8 +17,8 @@
17
17
  * limitations under the License.
18
18
  */
19
19
 
20
- import fs from 'node:fs';
21
- import path from 'node:path';
20
+ import fs from 'fs';
21
+ import path from 'path';
22
22
  import Locale from 'ilib-locale';
23
23
 
24
24
  import { isAlnum, isIdeo } from 'ilib-ctype';