@fgv/ts-bcp47 3.0.1-alpha.6 → 4.0.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/CHANGELOG.json +15 -0
- package/CHANGELOG.md +9 -1
- package/dist/ts-bcp47.d.ts +15 -15
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/packlets/bcp47/helpers.d.ts +3 -3
- package/lib/packlets/bcp47/helpers.js +3 -3
- package/lib/packlets/bcp47/helpers.js.map +1 -1
- package/lib/packlets/bcp47/languageTag.d.ts +7 -7
- package/lib/packlets/bcp47/languageTag.js +7 -7
- package/lib/packlets/bcp47/languageTag.js.map +1 -1
- package/lib/packlets/iana/common/converters.d.ts +2 -2
- package/lib/packlets/iana/common/converters.js +2 -2
- package/lib/packlets/iana/common/converters.js.map +1 -1
- package/lib/packlets/iana/common/utils.d.ts +1 -1
- package/lib/packlets/iana/common/utils.js +1 -1
- package/lib/packlets/iana/common/utils.js.map +1 -1
- package/lib/packlets/iana/jar/jarConverters.d.ts +2 -2
- package/lib/packlets/iana/jar/jarConverters.js +2 -2
- package/lib/packlets/iana/jar/jarConverters.js.map +1 -1
- package/package.json +20 -20
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-bcp47",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "4.0.0",
|
|
6
|
+
"tag": "@fgv/ts-bcp47_v4.0.0",
|
|
7
|
+
"date": "Tue, 14 May 2024 03:09:27 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "update dependencies"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "update generated api docs"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
4
19
|
{
|
|
5
20
|
"version": "3.0.0",
|
|
6
21
|
"tag": "@fgv/ts-bcp47_v3.0.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Change Log - @fgv/ts-bcp47
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 14 May 2024 03:09:27 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.0.0
|
|
6
|
+
Tue, 14 May 2024 03:09:27 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- update dependencies
|
|
11
|
+
- update generated api docs
|
|
4
12
|
|
|
5
13
|
## 3.0.0
|
|
6
14
|
Mon, 22 Jan 2024 07:00:18 GMT
|
package/dist/ts-bcp47.d.ts
CHANGED
|
@@ -157,19 +157,19 @@ declare namespace Csv {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
160
|
+
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
161
161
|
* containing entries of supplied template type `T`.
|
|
162
162
|
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
163
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.
|
|
163
|
+
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
164
164
|
* @public
|
|
165
165
|
*/
|
|
166
166
|
declare function datedRegistry<T, TC = unknown>(entryConverter: Converter<T, TC>): Converter<IDatedRegistry<T>, TC>;
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
169
|
+
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
170
170
|
* containing entries of supplied template type `T`.
|
|
171
171
|
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
172
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.
|
|
172
|
+
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
173
173
|
* @internal
|
|
174
174
|
*/
|
|
175
175
|
declare function datedRegistryFromJarRecords<T, TC = unknown>(entryConverter: Converter<T, TC>): Converter<IDatedRegistry<T>, TC>;
|
|
@@ -1272,7 +1272,7 @@ declare class LanguageTag {
|
|
|
1272
1272
|
* using optional configuration, if supplied.
|
|
1273
1273
|
* @param tag - The `string` tag from which the {@link Bcp47.LanguageTag | language tag}
|
|
1274
1274
|
* is te be constructed.
|
|
1275
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
1275
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
1276
1276
|
* to guide the validation and normalization of this tag.
|
|
1277
1277
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
1278
1278
|
* with details if an error occurs.
|
|
@@ -1284,7 +1284,7 @@ declare class LanguageTag {
|
|
|
1284
1284
|
* if supplied.
|
|
1285
1285
|
* @param tag - The {@link Bcp47.Subtags | subtags} from which the
|
|
1286
1286
|
* {@link Bcp47.LanguageTag | language tag} is te be constructed.
|
|
1287
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
1287
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
1288
1288
|
* to guide the validation and normalization of this tag.
|
|
1289
1289
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
1290
1290
|
* with details if an error occurs.
|
|
@@ -1296,7 +1296,7 @@ declare class LanguageTag {
|
|
|
1296
1296
|
* if supplied.
|
|
1297
1297
|
* @param from - The `string` tag or {@link Bcp47.Subtags | subtags} from
|
|
1298
1298
|
* which the {@link Bcp47.LanguageTag | language tag} is te be constructed.
|
|
1299
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
1299
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
1300
1300
|
* to guide the validation and normalization of this tag.
|
|
1301
1301
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
1302
1302
|
* with details if an error occurs.
|
|
@@ -1309,18 +1309,18 @@ declare class LanguageTag {
|
|
|
1309
1309
|
* @param fromValidity - The {@link Bcp47.TagValidity | validation level} of the supplied subtags.
|
|
1310
1310
|
* @param fromNormalization - The {@link Bcp47.TagNormalization | normalization level} fo the
|
|
1311
1311
|
* supplied subtags.
|
|
1312
|
-
* @param partialOptions - Any {@link Bcp47.
|
|
1312
|
+
* @param partialOptions - Any {@link Bcp47.ILanguageTagInitOptions | initialization options}.
|
|
1313
1313
|
* @returns `Success` with the corresponding {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
1314
1314
|
* with details if an error occurs.
|
|
1315
1315
|
* @internal
|
|
1316
1316
|
*/
|
|
1317
1317
|
protected static _createTransformed(subtags: ISubtags, fromValidity: TagValidity, fromNormalization: TagNormalization, partialOptions?: ILanguageTagInitOptions): Result<LanguageTag>;
|
|
1318
1318
|
/**
|
|
1319
|
-
* Gets a fully-specified {@link Bcp47.
|
|
1319
|
+
* Gets a fully-specified {@link Bcp47.ILanguageTagInitOptions} from partial or undefined
|
|
1320
1320
|
* options, substituting defaults as appropriate.
|
|
1321
|
-
* @param options - The {@link Bcp47.
|
|
1321
|
+
* @param options - The {@link Bcp47.ILanguageTagInitOptions} to be expanded, or `undefined`
|
|
1322
1322
|
* for default options.
|
|
1323
|
-
* @returns Fully-specified {@link Bcp47.
|
|
1323
|
+
* @returns Fully-specified {@link Bcp47.ILanguageTagInitOptions | init options}.
|
|
1324
1324
|
* @internal
|
|
1325
1325
|
*/
|
|
1326
1326
|
protected static _getOptions(options?: ILanguageTagInitOptions): Required<ILanguageTagInitOptions>;
|
|
@@ -1649,7 +1649,7 @@ declare class NormalizeTag {
|
|
|
1649
1649
|
}
|
|
1650
1650
|
|
|
1651
1651
|
/**
|
|
1652
|
-
* Gets the current date as an {@link Iana.YearMonthDaySpec}.
|
|
1652
|
+
* Gets the current date as an {@link Iana.Model.YearMonthDaySpec | YearMonthDaySpec }.
|
|
1653
1653
|
* @public
|
|
1654
1654
|
*/
|
|
1655
1655
|
declare function nowAsYearMonthDay(): YearMonthDaySpec_2;
|
|
@@ -2067,7 +2067,7 @@ declare class ScriptSubtagScope extends SubtagScopeWithRange<'script', ScriptSub
|
|
|
2067
2067
|
* @param t2 - Second tag to match, supplied as one of `string`, individual
|
|
2068
2068
|
* {@link Bcp47.Subtags | subtags}, or constructed
|
|
2069
2069
|
* {@link Bcp47.LanguageTag | language tag}.
|
|
2070
|
-
* @param options - (optional) A set of {@link Bcp47.
|
|
2070
|
+
* @param options - (optional) A set of {@link Bcp47.ILanguageTagInitOptions | language tag options}
|
|
2071
2071
|
* which control any necessary conversion or parsing.
|
|
2072
2072
|
* @returns A numeric value in the range 1.0 (exact match) to 0.0 (no match).
|
|
2073
2073
|
* @see For a set of common levels of similarity, see {@link Bcp47.tagSimilarity | similarity}.
|
|
@@ -2121,7 +2121,7 @@ declare function subtagsToString(subtags: ISubtags): string;
|
|
|
2121
2121
|
*
|
|
2122
2122
|
* @param from - The {@link Bcp47.LanguageSpec | language specifier} from which the tag is to
|
|
2123
2123
|
* be created.
|
|
2124
|
-
* @param options - (optional) The {@link Bcp47.
|
|
2124
|
+
* @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct
|
|
2125
2125
|
* and validate the tag.
|
|
2126
2126
|
* @returns `Success` with a valid {@link Bcp47.LanguageTag | language tag} or `Failure` with details
|
|
2127
2127
|
* if an error occurs.
|
|
@@ -2182,7 +2182,7 @@ declare namespace Tags {
|
|
|
2182
2182
|
* Creates an array of {@link Bcp47.LanguageTag | language tags} from an incoming array of
|
|
2183
2183
|
* {@link Bcp47.LanguageSpec | language specifiers}.
|
|
2184
2184
|
* @param from - The array of {@link Bcp47.LanguageSpec} to be converted.
|
|
2185
|
-
* @param options - (optional) The {@link Bcp47.
|
|
2185
|
+
* @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct
|
|
2186
2186
|
* and validate any created tags.
|
|
2187
2187
|
* @returns `Success` with an array of {@link Bcp47.LanguageTag | language tags}, or `Failure`
|
|
2188
2188
|
* with details if an error occurs.
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -18,7 +18,7 @@ export type LanguageSpec = string | ISubtags | LanguageTag;
|
|
|
18
18
|
*
|
|
19
19
|
* @param from - The {@link Bcp47.LanguageSpec | language specifier} from which the tag is to
|
|
20
20
|
* be created.
|
|
21
|
-
* @param options - (optional) The {@link Bcp47.
|
|
21
|
+
* @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct
|
|
22
22
|
* and validate the tag.
|
|
23
23
|
* @returns `Success` with a valid {@link Bcp47.LanguageTag | language tag} or `Failure` with details
|
|
24
24
|
* if an error occurs.
|
|
@@ -29,7 +29,7 @@ export declare function tag(from: LanguageSpec, options?: ILanguageTagInitOption
|
|
|
29
29
|
* Creates an array of {@link Bcp47.LanguageTag | language tags} from an incoming array of
|
|
30
30
|
* {@link Bcp47.LanguageSpec | language specifiers}.
|
|
31
31
|
* @param from - The array of {@link Bcp47.LanguageSpec} to be converted.
|
|
32
|
-
* @param options - (optional) The {@link Bcp47.
|
|
32
|
+
* @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct
|
|
33
33
|
* and validate any created tags.
|
|
34
34
|
* @returns `Success` with an array of {@link Bcp47.LanguageTag | language tags}, or `Failure`
|
|
35
35
|
* with details if an error occurs.
|
|
@@ -45,7 +45,7 @@ export declare function tags(from: LanguageSpec[], options?: ILanguageTagInitOpt
|
|
|
45
45
|
* @param t2 - Second tag to match, supplied as one of `string`, individual
|
|
46
46
|
* {@link Bcp47.Subtags | subtags}, or constructed
|
|
47
47
|
* {@link Bcp47.LanguageTag | language tag}.
|
|
48
|
-
* @param options - (optional) A set of {@link Bcp47.
|
|
48
|
+
* @param options - (optional) A set of {@link Bcp47.ILanguageTagInitOptions | language tag options}
|
|
49
49
|
* which control any necessary conversion or parsing.
|
|
50
50
|
* @returns A numeric value in the range 1.0 (exact match) to 0.0 (no match).
|
|
51
51
|
* @see For a set of common levels of similarity, see {@link Bcp47.tagSimilarity | similarity}.
|
|
@@ -35,7 +35,7 @@ const chooser_1 = require("./match/chooser");
|
|
|
35
35
|
*
|
|
36
36
|
* @param from - The {@link Bcp47.LanguageSpec | language specifier} from which the tag is to
|
|
37
37
|
* be created.
|
|
38
|
-
* @param options - (optional) The {@link Bcp47.
|
|
38
|
+
* @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct
|
|
39
39
|
* and validate the tag.
|
|
40
40
|
* @returns `Success` with a valid {@link Bcp47.LanguageTag | language tag} or `Failure` with details
|
|
41
41
|
* if an error occurs.
|
|
@@ -50,7 +50,7 @@ exports.tag = tag;
|
|
|
50
50
|
* Creates an array of {@link Bcp47.LanguageTag | language tags} from an incoming array of
|
|
51
51
|
* {@link Bcp47.LanguageSpec | language specifiers}.
|
|
52
52
|
* @param from - The array of {@link Bcp47.LanguageSpec} to be converted.
|
|
53
|
-
* @param options - (optional) The {@link Bcp47.
|
|
53
|
+
* @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct
|
|
54
54
|
* and validate any created tags.
|
|
55
55
|
* @returns `Success` with an array of {@link Bcp47.LanguageTag | language tags}, or `Failure`
|
|
56
56
|
* with details if an error occurs.
|
|
@@ -69,7 +69,7 @@ exports.tags = tags;
|
|
|
69
69
|
* @param t2 - Second tag to match, supplied as one of `string`, individual
|
|
70
70
|
* {@link Bcp47.Subtags | subtags}, or constructed
|
|
71
71
|
* {@link Bcp47.LanguageTag | language tag}.
|
|
72
|
-
* @param options - (optional) A set of {@link Bcp47.
|
|
72
|
+
* @param options - (optional) A set of {@link Bcp47.ILanguageTagInitOptions | language tag options}
|
|
73
73
|
* which control any necessary conversion or parsing.
|
|
74
74
|
* @returns A numeric value in the range 1.0 (exact match) to 0.0 (no match).
|
|
75
75
|
* @see For a set of common levels of similarity, see {@link Bcp47.tagSimilarity | similarity}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/packlets/bcp47/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAA4D;AAE5D,+CAAqE;AACrE,mCAAoD;AACpD,6CAA2E;AAU3E;;;;;;;;;;;;;;GAcG;AACH,2DAA2D;AAC3D,SAAgB,GAAG,CAAC,IAAkB,EAAE,OAAiC;IACvE,OAAO,IAAI,YAAY,yBAAW,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC;AAFD,kBAEC;AAED;;;;;;;;;GASG;AACH,SAAgB,IAAI,CAAC,IAAoB,EAAE,OAAiC;IAC1E,OAAO,IAAA,qBAAU,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAFD,oBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,yDAAyD;AACzD,SAAgB,UAAU,CACxB,EAAgB,EAChB,EAAgB,EAChB,OAAiC;IAEjC,OAAO,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QAChD,OAAO,IAAA,kBAAO,EAAC,IAAI,iCAAyB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;AACL,CAAC;AARD,gCAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,MAAM,CACpB,OAAuB,EACvB,SAAyB,EACzB,OAA2D;IAE3D,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5C,OAAO,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9C,OAAO,IAAA,kBAAO,EAAC,IAAI,yBAAe,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,wBAUC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, mapResults, succeed } from '@fgv/ts-utils';\nimport { ISubtags } from './common';\nimport { ILanguageTagInitOptions, LanguageTag } from './languageTag';\nimport { LanguageSimilarityMatcher } from './match';\nimport { ILanguageChooserOptions, LanguageChooser } from './match/chooser';\n\n/**\n * Any of the possible ways to represent a language - as a `string`,\n * parsed {@link Bcp47.Subtags | subtags} or an instantiated\n * {@link Bcp47.LanguageTag | language tag}.\n * @public\n */\nexport type LanguageSpec = string | ISubtags | LanguageTag;\n\n/**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a {@link Bcp47.LanguageSpec | language specifier}\n *\n * The supplied initializer must be at least\n * {@link https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.9 | well-formed according to RFC 5646}.\n * Higher degrees of validation along with any normalizations may be optionally specified.\n *\n * @param from - The {@link Bcp47.LanguageSpec | language specifier} from which the tag is to\n * be created.\n * @param options - (optional) The {@link Bcp47.
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/packlets/bcp47/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAA4D;AAE5D,+CAAqE;AACrE,mCAAoD;AACpD,6CAA2E;AAU3E;;;;;;;;;;;;;;GAcG;AACH,2DAA2D;AAC3D,SAAgB,GAAG,CAAC,IAAkB,EAAE,OAAiC;IACvE,OAAO,IAAI,YAAY,yBAAW,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC;AAFD,kBAEC;AAED;;;;;;;;;GASG;AACH,SAAgB,IAAI,CAAC,IAAoB,EAAE,OAAiC;IAC1E,OAAO,IAAA,qBAAU,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAFD,oBAEC;AAED;;;;;;;;;;;;;;GAcG;AACH,yDAAyD;AACzD,SAAgB,UAAU,CACxB,EAAgB,EAChB,EAAgB,EAChB,OAAiC;IAEjC,OAAO,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QAChD,OAAO,IAAA,kBAAO,EAAC,IAAI,iCAAyB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;AACL,CAAC;AARD,gCAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,MAAM,CACpB,OAAuB,EACvB,SAAyB,EACzB,OAA2D;IAE3D,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5C,OAAO,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9C,OAAO,IAAA,kBAAO,EAAC,IAAI,yBAAe,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,wBAUC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, mapResults, succeed } from '@fgv/ts-utils';\nimport { ISubtags } from './common';\nimport { ILanguageTagInitOptions, LanguageTag } from './languageTag';\nimport { LanguageSimilarityMatcher } from './match';\nimport { ILanguageChooserOptions, LanguageChooser } from './match/chooser';\n\n/**\n * Any of the possible ways to represent a language - as a `string`,\n * parsed {@link Bcp47.Subtags | subtags} or an instantiated\n * {@link Bcp47.LanguageTag | language tag}.\n * @public\n */\nexport type LanguageSpec = string | ISubtags | LanguageTag;\n\n/**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a {@link Bcp47.LanguageSpec | language specifier}\n *\n * The supplied initializer must be at least\n * {@link https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.9 | well-formed according to RFC 5646}.\n * Higher degrees of validation along with any normalizations may be optionally specified.\n *\n * @param from - The {@link Bcp47.LanguageSpec | language specifier} from which the tag is to\n * be created.\n * @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct\n * and validate the tag.\n * @returns `Success` with a valid {@link Bcp47.LanguageTag | language tag} or `Failure` with details\n * if an error occurs.\n * @public\n */\n/* c8 ignore next 3 - tests applied for wrapped function */\nexport function tag(from: LanguageSpec, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n return from instanceof LanguageTag ? succeed(from) : LanguageTag.create(from, options);\n}\n\n/**\n * Creates an array of {@link Bcp47.LanguageTag | language tags} from an incoming array of\n * {@link Bcp47.LanguageSpec | language specifiers}.\n * @param from - The array of {@link Bcp47.LanguageSpec} to be converted.\n * @param options - (optional) The {@link Bcp47.ILanguageTagInitOptions | options} used to construct\n * and validate any created tags.\n * @returns `Success` with an array of {@link Bcp47.LanguageTag | language tags}, or `Failure`\n * with details if an error occurs.\n * @public\n */\nexport function tags(from: LanguageSpec[], options?: ILanguageTagInitOptions): Result<LanguageTag[]> {\n return mapResults(from.map((f) => tag(f, options)));\n}\n\n/**\n * Determine how similar two language tags are to each other.\n *\n * @param t1 - First tag to match, supplied as one of `string`, individual\n * {@link Bcp47.Subtags | subtags}, or constructed\n * {@link Bcp47.LanguageTag | language tag}.\n * @param t2 - Second tag to match, supplied as one of `string`, individual\n * {@link Bcp47.Subtags | subtags}, or constructed\n * {@link Bcp47.LanguageTag | language tag}.\n * @param options - (optional) A set of {@link Bcp47.ILanguageTagInitOptions | language tag options}\n * which control any necessary conversion or parsing.\n * @returns A numeric value in the range 1.0 (exact match) to 0.0 (no match).\n * @see For a set of common levels of similarity, see {@link Bcp47.tagSimilarity | similarity}.\n * @public\n */\n/* c8 ignore next - tests applied for wrapped function */\nexport function similarity(\n t1: LanguageSpec,\n t2: LanguageSpec,\n options?: ILanguageTagInitOptions\n): Result<number> {\n return tags([t1, t2], options).onSuccess((tags) => {\n return succeed(new LanguageSimilarityMatcher().matchLanguageTags(tags[0], tags[1]));\n });\n}\n\n/**\n * Matches a list of desired {@link Bcp47.LanguageSpec | languages} to a list of available {@link Bcp47.LanguageSpec | languages},\n * return a list of matching languages ordered from best to worst.\n * @param desired - An array of {@link Bcp47.LanguageSpec | language specifications} containing an ordered list of preferred languages.\n * @param available - An array of {@link Bcp47.LanguageSpec | language specifications} containing an unordered list of available languages.\n * @param options - (optional) Parameters to control language tag conversion or comparison\n * @returns `Success` with an ordered list of matching {@link Bcp47.LanguageTag | languages}, or `Failure` with details if\n * an error occurs.\n * @public\n */\nexport function choose(\n desired: LanguageSpec[],\n available: LanguageSpec[],\n options?: ILanguageTagInitOptions & ILanguageChooserOptions\n): Result<LanguageTag[]> {\n return tags(desired, options).onSuccess((w) => {\n return tags(available, options).onSuccess((h) => {\n return succeed(new LanguageChooser().filterLanguageTags(w, h, options));\n });\n });\n}\n"]}
|
|
@@ -129,7 +129,7 @@ export declare class LanguageTag {
|
|
|
129
129
|
* using optional configuration, if supplied.
|
|
130
130
|
* @param tag - The `string` tag from which the {@link Bcp47.LanguageTag | language tag}
|
|
131
131
|
* is te be constructed.
|
|
132
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
132
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
133
133
|
* to guide the validation and normalization of this tag.
|
|
134
134
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
135
135
|
* with details if an error occurs.
|
|
@@ -141,7 +141,7 @@ export declare class LanguageTag {
|
|
|
141
141
|
* if supplied.
|
|
142
142
|
* @param tag - The {@link Bcp47.Subtags | subtags} from which the
|
|
143
143
|
* {@link Bcp47.LanguageTag | language tag} is te be constructed.
|
|
144
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
144
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
145
145
|
* to guide the validation and normalization of this tag.
|
|
146
146
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
147
147
|
* with details if an error occurs.
|
|
@@ -153,7 +153,7 @@ export declare class LanguageTag {
|
|
|
153
153
|
* if supplied.
|
|
154
154
|
* @param from - The `string` tag or {@link Bcp47.Subtags | subtags} from
|
|
155
155
|
* which the {@link Bcp47.LanguageTag | language tag} is te be constructed.
|
|
156
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
156
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
157
157
|
* to guide the validation and normalization of this tag.
|
|
158
158
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
159
159
|
* with details if an error occurs.
|
|
@@ -166,18 +166,18 @@ export declare class LanguageTag {
|
|
|
166
166
|
* @param fromValidity - The {@link Bcp47.TagValidity | validation level} of the supplied subtags.
|
|
167
167
|
* @param fromNormalization - The {@link Bcp47.TagNormalization | normalization level} fo the
|
|
168
168
|
* supplied subtags.
|
|
169
|
-
* @param partialOptions - Any {@link Bcp47.
|
|
169
|
+
* @param partialOptions - Any {@link Bcp47.ILanguageTagInitOptions | initialization options}.
|
|
170
170
|
* @returns `Success` with the corresponding {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
171
171
|
* with details if an error occurs.
|
|
172
172
|
* @internal
|
|
173
173
|
*/
|
|
174
174
|
protected static _createTransformed(subtags: ISubtags, fromValidity: TagValidity, fromNormalization: TagNormalization, partialOptions?: ILanguageTagInitOptions): Result<LanguageTag>;
|
|
175
175
|
/**
|
|
176
|
-
* Gets a fully-specified {@link Bcp47.
|
|
176
|
+
* Gets a fully-specified {@link Bcp47.ILanguageTagInitOptions} from partial or undefined
|
|
177
177
|
* options, substituting defaults as appropriate.
|
|
178
|
-
* @param options - The {@link Bcp47.
|
|
178
|
+
* @param options - The {@link Bcp47.ILanguageTagInitOptions} to be expanded, or `undefined`
|
|
179
179
|
* for default options.
|
|
180
|
-
* @returns Fully-specified {@link Bcp47.
|
|
180
|
+
* @returns Fully-specified {@link Bcp47.ILanguageTagInitOptions | init options}.
|
|
181
181
|
* @internal
|
|
182
182
|
*/
|
|
183
183
|
protected static _getOptions(options?: ILanguageTagInitOptions): Required<ILanguageTagInitOptions>;
|
|
@@ -212,7 +212,7 @@ class LanguageTag {
|
|
|
212
212
|
* using optional configuration, if supplied.
|
|
213
213
|
* @param tag - The `string` tag from which the {@link Bcp47.LanguageTag | language tag}
|
|
214
214
|
* is te be constructed.
|
|
215
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
215
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
216
216
|
* to guide the validation and normalization of this tag.
|
|
217
217
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
218
218
|
* with details if an error occurs.
|
|
@@ -229,7 +229,7 @@ class LanguageTag {
|
|
|
229
229
|
* if supplied.
|
|
230
230
|
* @param tag - The {@link Bcp47.Subtags | subtags} from which the
|
|
231
231
|
* {@link Bcp47.LanguageTag | language tag} is te be constructed.
|
|
232
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
232
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
233
233
|
* to guide the validation and normalization of this tag.
|
|
234
234
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
235
235
|
* with details if an error occurs.
|
|
@@ -243,7 +243,7 @@ class LanguageTag {
|
|
|
243
243
|
* if supplied.
|
|
244
244
|
* @param from - The `string` tag or {@link Bcp47.Subtags | subtags} from
|
|
245
245
|
* which the {@link Bcp47.LanguageTag | language tag} is te be constructed.
|
|
246
|
-
* @param options - (optional) set of {@link Bcp47.
|
|
246
|
+
* @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}
|
|
247
247
|
* to guide the validation and normalization of this tag.
|
|
248
248
|
* @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
249
249
|
* with details if an error occurs.
|
|
@@ -263,7 +263,7 @@ class LanguageTag {
|
|
|
263
263
|
* @param fromValidity - The {@link Bcp47.TagValidity | validation level} of the supplied subtags.
|
|
264
264
|
* @param fromNormalization - The {@link Bcp47.TagNormalization | normalization level} fo the
|
|
265
265
|
* supplied subtags.
|
|
266
|
-
* @param partialOptions - Any {@link Bcp47.
|
|
266
|
+
* @param partialOptions - Any {@link Bcp47.ILanguageTagInitOptions | initialization options}.
|
|
267
267
|
* @returns `Success` with the corresponding {@link Bcp47.LanguageTag | language tag} or `Failure`
|
|
268
268
|
* with details if an error occurs.
|
|
269
269
|
* @internal
|
|
@@ -281,11 +281,11 @@ class LanguageTag {
|
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
|
-
* Gets a fully-specified {@link Bcp47.
|
|
284
|
+
* Gets a fully-specified {@link Bcp47.ILanguageTagInitOptions} from partial or undefined
|
|
285
285
|
* options, substituting defaults as appropriate.
|
|
286
|
-
* @param options - The {@link Bcp47.
|
|
286
|
+
* @param options - The {@link Bcp47.ILanguageTagInitOptions} to be expanded, or `undefined`
|
|
287
287
|
* for default options.
|
|
288
|
-
* @returns Fully-specified {@link Bcp47.
|
|
288
|
+
* @returns Fully-specified {@link Bcp47.ILanguageTagInitOptions | init options}.
|
|
289
289
|
* @internal
|
|
290
290
|
*/
|
|
291
291
|
static _getOptions(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"languageTag.js","sourceRoot":"","sources":["../../../src/packlets/bcp47/languageTag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAgC;AAEhC,4CAA+D;AAC/D,qCAA2E;AAC3E,mDAA0E;AAC1E,gDAA6D;AAE7D,iEAA8D;AAC9D,2DAAwD;AACxD,mDAA+C;AAC/C,6CAA2C;AAsB3C;;;GAGG;AACH,MAAa,WAAW;IA0DtB;;;;;;;;;;;OAWG;IACH,YACE,OAAiB,EACjB,QAAqB,EACrB,aAA+B,EAC/B,IAA6B;QAE7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,mBAAM,OAAO,EAAG,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAA,wBAAe,EAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,2CAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAE7D,IAAI,QAAQ,KAAK,gBAAgB,EAAE,CAAC;YAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;aAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,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AAQ;QACb,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AAxZD,kCAwZC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Iana from '../iana';\n\nimport { Result, captureResult, succeed } from '@fgv/ts-utils';\nimport { ISubtags, UndeterminedLanguage, subtagsToString } from './common';\nimport { TagNormalization, mostNormalized } from './normalization/common';\nimport { TagValidity, mostValid } from './validation/common';\n\nimport { LanguageRegistryData } from './languageRegistryData';\nimport { LanguageTagParser } from './languageTagParser';\nimport { NormalizeTag } from './normalization';\nimport { ValidateTag } from './validation';\n\n/**\n * Initialization options for parsing or creation of {@link Bcp47.LanguageTag | language tag} objects.\n * @public\n */\nexport interface ILanguageTagInitOptions {\n /**\n * Desired {@link Bcp47.TagValidity | validity level} (optional).\n */\n validity?: TagValidity;\n /**\n * Desired {@link Bcp47.TagNormalization | normalization level} (optional).\n */\n normalization?: TagNormalization;\n /**\n * The {@link Iana.LanguageRegistries | IANA language subtag and extension registries} to\n * be used for the request (optional).\n */\n iana?: Iana.LanguageRegistries;\n}\n\n/**\n * Represents a single BCP-47 language tag.\n * @public\n */\nexport class LanguageTag {\n /**\n * The individual {@link Bcp47.Subtags | subtags} for\n * this language tag.\n */\n public readonly subtags: Readonly<ISubtags>;\n\n /**\n * A string representation of this language tag.\n */\n public readonly tag: string;\n\n /**\n * Details about this language tag from the IANA language\n * registries.\n */\n public readonly registry: LanguageRegistryData;\n\n /**\n * @internal\n */\n protected readonly _iana: Iana.LanguageRegistries;\n\n /**\n * @internal\n */\n protected _validity: TagValidity;\n\n /**\n * @internal\n */\n protected _normalization: TagNormalization;\n\n /**\n * @internal\n */\n protected _isValid: undefined | boolean;\n\n /**\n * @internal\n */\n protected _isStrictlyValid: undefined | boolean;\n\n /**\n * @internal\n */\n protected _isCanonical: undefined | boolean;\n\n /**\n * @internal\n */\n protected _isPreferred: undefined | boolean;\n\n /**\n * @internal\n */\n protected _suppressedScript: undefined | Iana.LanguageSubtags.ScriptSubtag | false;\n\n /**\n * Constructs a {@link Bcp47.LanguageTag | LanguageTag }.\n * @param subtags - The {@link Bcp47.Subtags | subtags } from\n * which the tag is constructed.\n * @param validity - Known {@link Bcp47.TagValidity | validation level} of the\n * supplied subtags.\n * @param normalization - Known {@link Bcp47.TagNormalization | normalization level}\n * of the supplied subtags.\n * @param iana - The {@link Iana.LanguageRegistries} used to validate and normalize\n * this tag.\n * @internal\n */\n protected constructor(\n subtags: ISubtags,\n validity: TagValidity,\n normalization: TagNormalization,\n iana: Iana.LanguageRegistries\n ) {\n this.subtags = Object.freeze({ ...subtags });\n this._normalization = normalization;\n this._validity = validity;\n this.tag = subtagsToString(subtags);\n this._iana = iana;\n this.registry = new LanguageRegistryData(this.subtags, iana);\n\n if (validity === 'strictly-valid') {\n this._isStrictlyValid = true;\n this._isValid = true;\n } else if (validity === 'valid') {\n this._isValid = true;\n }\n\n if (normalization === 'preferred') {\n this._isPreferred = true;\n this._isCanonical = true;\n } else if (normalization === 'canonical') {\n this._isCanonical = true;\n }\n }\n\n /**\n * The effective script of this language tag, if known.\n * The effective script is the script subtag in the tag itself,\n * if present, or the `Suppress-Script` defined in the\n * {@link https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry | IANA subtag registry}\n * for the primary language of this tag. Can be `undefined`\n * if neither the tag nor the IANA registry define a script.\n */\n public get effectiveScript(): Iana.LanguageSubtags.ScriptSubtag | undefined {\n return this.subtags.script ?? this.getSuppressedScript();\n }\n\n /**\n * Determines if this tag represents the special `undetermined` language.\n */\n public get isUndetermined(): boolean {\n /* c8 ignore next */\n return this.subtags.primaryLanguage?.toLowerCase() === UndeterminedLanguage;\n }\n\n /**\n * Whether this language tag is valid.\n */\n public get isValid(): boolean {\n if (this._isValid === undefined) {\n this._isValid = ValidateTag.isValid(this.subtags);\n if (this._isValid) {\n this._validity = 'valid';\n }\n }\n return this._isValid === true;\n }\n\n /**\n * Whether if this language tag is strictly valid.\n */\n public get isStrictlyValid(): boolean {\n if (this._isStrictlyValid === undefined) {\n this._isStrictlyValid = ValidateTag.isStrictlyValid(this.subtags);\n if (this._isStrictlyValid) {\n this._validity = 'strictly-valid';\n }\n }\n return this._isStrictlyValid === true;\n }\n\n /**\n * Whether this language tag is in canonical form.\n */\n public get isCanonical(): boolean {\n if (this._isCanonical === undefined) {\n this._isCanonical = ValidateTag.isCanonical(this.subtags);\n if (this._isCanonical) {\n this._normalization = 'canonical';\n }\n }\n return this._isCanonical === true;\n }\n\n /**\n * Whether this language tag is in preferred form.\n */\n public get isPreferred(): boolean {\n if (this._isPreferred === undefined) {\n this._isPreferred = ValidateTag.isInPreferredForm(this.subtags);\n if (this._isPreferred) {\n this._normalization = 'preferred';\n }\n }\n return this._isPreferred === true;\n }\n\n /**\n * Whether this language tag is a grandfathered tag.\n */\n public get isGrandfathered(): boolean {\n return this.subtags.grandfathered !== undefined;\n }\n\n /**\n * Gets a text description of this tag.\n */\n public get description(): string {\n const parts: string[] = [];\n if (!this.subtags.grandfathered) {\n if (this.registry.primaryLanguage || this.subtags.primaryLanguage) {\n parts.push((this.registry.primaryLanguage?.description[0] ?? this.subtags.primaryLanguage)!);\n }\n if (this.registry.extlangs) {\n for (const e of this.registry.extlangs) {\n parts.push(`/ ${e.registry?.description[0] ?? e.subtag}`);\n }\n }\n if (this.subtags.script) {\n parts.push(`in ${this.registry.script?.description[0] ?? this.subtags.script} script`);\n }\n if (this.subtags.region) {\n parts.push(`as spoken in ${this.registry.region?.description[0] ?? this.subtags.region}`);\n }\n if (this.registry.variants && this.registry.variants.length > 0) {\n for (const e of this.registry.variants) {\n parts.push(`(${e.registry?.description[0] ?? e.subtag})`);\n }\n }\n if (this.registry.extensions && this.registry.extensions.length > 0) {\n for (const e of this.registry.extensions) {\n parts.push(`(${e.registry?.description[0] ?? `-${e.singleton}`} \"${e.value}\")`);\n }\n }\n if (this.subtags.privateUse && this.subtags.privateUse.length > 0) {\n parts.push(`(-x \"${this.subtags.privateUse.join('-')}\")`);\n }\n } else {\n parts.push(`${this.tag} (grandfathered)`);\n }\n return parts.join(' ');\n }\n\n /**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a supplied `string` tag\n * using optional configuration, if supplied.\n * @param tag - The `string` tag from which the {@link Bcp47.LanguageTag | language tag}\n * is te be constructed.\n * @param options - (optional) set of {@link Bcp47.LanguageTagInitOptions | init options}\n * to guide the validation and normalization of this tag.\n * @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n */\n public static createFromTag(tag: string, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n options = this._getOptions(options);\n\n return LanguageTagParser.parse(tag, options.iana).onSuccess((subtags) => {\n return this._createTransformed(subtags, 'unknown', 'unknown', options);\n });\n }\n\n /**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a supplied\n * {@link Bcp47.Subtags | subtags} using optional configuration,\n * if supplied.\n * @param tag - The {@link Bcp47.Subtags | subtags} from which the\n * {@link Bcp47.LanguageTag | language tag} is te be constructed.\n * @param options - (optional) set of {@link Bcp47.LanguageTagInitOptions | init options}\n * to guide the validation and normalization of this tag.\n * @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n */\n public static createFromSubtags(subtags: ISubtags, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n return this._createTransformed(subtags, 'unknown', 'unknown', options);\n }\n\n /**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a supplied `string`\n * tag or {@link Bcp47.Subtags | subtags} using optional configuration,\n * if supplied.\n * @param from - The `string` tag or {@link Bcp47.Subtags | subtags} from\n * which the {@link Bcp47.LanguageTag | language tag} is te be constructed.\n * @param options - (optional) set of {@link Bcp47.LanguageTagInitOptions | init options}\n * to guide the validation and normalization of this tag.\n * @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n */\n public static create(from: string | ISubtags, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n if (typeof from === 'string') {\n return this.createFromTag(from, options);\n } else {\n return this.createFromSubtags(from, options);\n }\n }\n\n /**\n * Constructs a new {@link Bcp47.LanguageTag | language tag} by applying appropriate transformations\n * to as supplied {@link Bcp47.Subtags | Bcp47.Subtags}.\n * @param subtags - The {@link Bcp47.Subtags | subtags} which represent the tag.\n * @param fromValidity - The {@link Bcp47.TagValidity | validation level} of the supplied subtags.\n * @param fromNormalization - The {@link Bcp47.TagNormalization | normalization level} fo the\n * supplied subtags.\n * @param partialOptions - Any {@link Bcp47.LanguageTagInitOptions | initialization options}.\n * @returns `Success` with the corresponding {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n * @internal\n */\n protected static _createTransformed(\n subtags: ISubtags,\n fromValidity: TagValidity,\n fromNormalization: TagNormalization,\n partialOptions?: ILanguageTagInitOptions\n ): Result<LanguageTag> {\n const options = this._getOptions(partialOptions);\n return ValidateTag.validateSubtags(subtags, options.validity, fromValidity)\n .onSuccess(() => {\n return NormalizeTag.normalizeSubtags(subtags, options.normalization, fromNormalization);\n })\n .onSuccess((normalized) => {\n const validity = mostValid(fromValidity, options.validity);\n const normalization = mostNormalized(fromNormalization, options.normalization);\n return captureResult(() => new LanguageTag(normalized, validity, normalization, options.iana));\n });\n }\n\n /**\n * Gets a fully-specified {@link Bcp47.LanguageTagInitOptions} from partial or undefined\n * options, substituting defaults as appropriate.\n * @param options - The {@link Bcp47.LanguageTagInitOptions} to be expanded, or `undefined`\n * for default options.\n * @returns Fully-specified {@link Bcp47.LanguageTagInitOptions | init options}.\n * @internal\n */\n protected static _getOptions(options?: ILanguageTagInitOptions): Required<ILanguageTagInitOptions> {\n return {\n iana: options?.iana ?? Iana.DefaultRegistries.languageRegistries,\n validity: options?.validity ?? 'well-formed',\n normalization: options?.normalization ?? 'none'\n };\n }\n\n /**\n * Returns the `Suppress-Script` value defined for the primary language of this tag,\n * regardless of whether a different script is defined in this subtag.\n * @returns The suppress-script defined for the primary language, or undefined if\n * the primary language is invalid or has no defined suppressed script.\n */\n public getSuppressedScript(): Iana.LanguageSubtags.ScriptSubtag | undefined {\n if (this._suppressedScript === undefined) {\n this._suppressedScript = false;\n if (this.subtags.primaryLanguage) {\n const language = this._iana.subtags.languages.tryGet(this.subtags.primaryLanguage);\n if (language?.suppressScript !== undefined) {\n this._suppressedScript = language.suppressScript;\n }\n }\n }\n return this._suppressedScript ? this._suppressedScript : undefined;\n }\n\n /**\n * Gets a confirmed valid representation of this language tag.\n * @returns `Success` with a valid representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be validated.\n */\n public toValid(): Result<LanguageTag> {\n if (this.isValid) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: 'valid',\n normalization: this._normalization\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a confirmed strictly valid representation of this language tag.\n * @returns `Success` with a strictly valid representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be strictly validated.\n */\n public toStrictlyValid(): Result<LanguageTag> {\n if (this.isStrictlyValid) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: 'strictly-valid',\n normalization: this._normalization\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a confirmed canonical representation of this language tag.\n * @returns `Success` with a canonical representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be normalized to canonical form.\n */\n public toCanonical(): Result<LanguageTag> {\n if (this.isCanonical) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: this._validity,\n normalization: 'canonical'\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a confirmed preferred representation of this language tag.\n * @returns `Success` with a preferred representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be normalized to preferred form.\n */\n public toPreferred(): Result<LanguageTag> {\n if (this.isPreferred) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: 'valid', // preferred requires validity\n normalization: 'preferred'\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a string representation of this language tag.\n * @returns A string representation of this language tag.\n */\n public toString(): string {\n return this.tag;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"languageTag.js","sourceRoot":"","sources":["../../../src/packlets/bcp47/languageTag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAgC;AAEhC,4CAA+D;AAC/D,qCAA2E;AAC3E,mDAA0E;AAC1E,gDAA6D;AAE7D,iEAA8D;AAC9D,2DAAwD;AACxD,mDAA+C;AAC/C,6CAA2C;AAsB3C;;;GAGG;AACH,MAAa,WAAW;IA0DtB;;;;;;;;;;;OAWG;I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CAAC,KAAK;YAChB,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,aAAa,EAAE,WAAW;SAC3B,CAAC;QACF,OAAO,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACpG,CAAC;IAED;;;;OAIG;IACI,WAAW;QAChB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,MAAM,OAAO,GAA4B;YACvC,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,QAAQ,EAAE,OAAO,EAAE,8BAA8B;YACjD,aAAa,EAAE,WAAW;SAC3B,CAAC;QACF,OAAO,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACpG,CAAC;IAED;;;OAGG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AAxZD,kCAwZC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Iana from '../iana';\n\nimport { Result, captureResult, succeed } from '@fgv/ts-utils';\nimport { ISubtags, UndeterminedLanguage, subtagsToString } from './common';\nimport { TagNormalization, mostNormalized } from './normalization/common';\nimport { TagValidity, mostValid } from './validation/common';\n\nimport { LanguageRegistryData } from './languageRegistryData';\nimport { LanguageTagParser } from './languageTagParser';\nimport { NormalizeTag } from './normalization';\nimport { ValidateTag } from './validation';\n\n/**\n * Initialization options for parsing or creation of {@link Bcp47.LanguageTag | language tag} objects.\n * @public\n */\nexport interface ILanguageTagInitOptions {\n /**\n * Desired {@link Bcp47.TagValidity | validity level} (optional).\n */\n validity?: TagValidity;\n /**\n * Desired {@link Bcp47.TagNormalization | normalization level} (optional).\n */\n normalization?: TagNormalization;\n /**\n * The {@link Iana.LanguageRegistries | IANA language subtag and extension registries} to\n * be used for the request (optional).\n */\n iana?: Iana.LanguageRegistries;\n}\n\n/**\n * Represents a single BCP-47 language tag.\n * @public\n */\nexport class LanguageTag {\n /**\n * The individual {@link Bcp47.Subtags | subtags} for\n * this language tag.\n */\n public readonly subtags: Readonly<ISubtags>;\n\n /**\n * A string representation of this language tag.\n */\n public readonly tag: string;\n\n /**\n * Details about this language tag from the IANA language\n * registries.\n */\n public readonly registry: LanguageRegistryData;\n\n /**\n * @internal\n */\n protected readonly _iana: Iana.LanguageRegistries;\n\n /**\n * @internal\n */\n protected _validity: TagValidity;\n\n /**\n * @internal\n */\n protected _normalization: TagNormalization;\n\n /**\n * @internal\n */\n protected _isValid: undefined | boolean;\n\n /**\n * @internal\n */\n protected _isStrictlyValid: undefined | boolean;\n\n /**\n * @internal\n */\n protected _isCanonical: undefined | boolean;\n\n /**\n * @internal\n */\n protected _isPreferred: undefined | boolean;\n\n /**\n * @internal\n */\n protected _suppressedScript: undefined | Iana.LanguageSubtags.ScriptSubtag | false;\n\n /**\n * Constructs a {@link Bcp47.LanguageTag | LanguageTag }.\n * @param subtags - The {@link Bcp47.Subtags | subtags } from\n * which the tag is constructed.\n * @param validity - Known {@link Bcp47.TagValidity | validation level} of the\n * supplied subtags.\n * @param normalization - Known {@link Bcp47.TagNormalization | normalization level}\n * of the supplied subtags.\n * @param iana - The {@link Iana.LanguageRegistries} used to validate and normalize\n * this tag.\n * @internal\n */\n protected constructor(\n subtags: ISubtags,\n validity: TagValidity,\n normalization: TagNormalization,\n iana: Iana.LanguageRegistries\n ) {\n this.subtags = Object.freeze({ ...subtags });\n this._normalization = normalization;\n this._validity = validity;\n this.tag = subtagsToString(subtags);\n this._iana = iana;\n this.registry = new LanguageRegistryData(this.subtags, iana);\n\n if (validity === 'strictly-valid') {\n this._isStrictlyValid = true;\n this._isValid = true;\n } else if (validity === 'valid') {\n this._isValid = true;\n }\n\n if (normalization === 'preferred') {\n this._isPreferred = true;\n this._isCanonical = true;\n } else if (normalization === 'canonical') {\n this._isCanonical = true;\n }\n }\n\n /**\n * The effective script of this language tag, if known.\n * The effective script is the script subtag in the tag itself,\n * if present, or the `Suppress-Script` defined in the\n * {@link https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry | IANA subtag registry}\n * for the primary language of this tag. Can be `undefined`\n * if neither the tag nor the IANA registry define a script.\n */\n public get effectiveScript(): Iana.LanguageSubtags.ScriptSubtag | undefined {\n return this.subtags.script ?? this.getSuppressedScript();\n }\n\n /**\n * Determines if this tag represents the special `undetermined` language.\n */\n public get isUndetermined(): boolean {\n /* c8 ignore next */\n return this.subtags.primaryLanguage?.toLowerCase() === UndeterminedLanguage;\n }\n\n /**\n * Whether this language tag is valid.\n */\n public get isValid(): boolean {\n if (this._isValid === undefined) {\n this._isValid = ValidateTag.isValid(this.subtags);\n if (this._isValid) {\n this._validity = 'valid';\n }\n }\n return this._isValid === true;\n }\n\n /**\n * Whether if this language tag is strictly valid.\n */\n public get isStrictlyValid(): boolean {\n if (this._isStrictlyValid === undefined) {\n this._isStrictlyValid = ValidateTag.isStrictlyValid(this.subtags);\n if (this._isStrictlyValid) {\n this._validity = 'strictly-valid';\n }\n }\n return this._isStrictlyValid === true;\n }\n\n /**\n * Whether this language tag is in canonical form.\n */\n public get isCanonical(): boolean {\n if (this._isCanonical === undefined) {\n this._isCanonical = ValidateTag.isCanonical(this.subtags);\n if (this._isCanonical) {\n this._normalization = 'canonical';\n }\n }\n return this._isCanonical === true;\n }\n\n /**\n * Whether this language tag is in preferred form.\n */\n public get isPreferred(): boolean {\n if (this._isPreferred === undefined) {\n this._isPreferred = ValidateTag.isInPreferredForm(this.subtags);\n if (this._isPreferred) {\n this._normalization = 'preferred';\n }\n }\n return this._isPreferred === true;\n }\n\n /**\n * Whether this language tag is a grandfathered tag.\n */\n public get isGrandfathered(): boolean {\n return this.subtags.grandfathered !== undefined;\n }\n\n /**\n * Gets a text description of this tag.\n */\n public get description(): string {\n const parts: string[] = [];\n if (!this.subtags.grandfathered) {\n if (this.registry.primaryLanguage || this.subtags.primaryLanguage) {\n parts.push((this.registry.primaryLanguage?.description[0] ?? this.subtags.primaryLanguage)!);\n }\n if (this.registry.extlangs) {\n for (const e of this.registry.extlangs) {\n parts.push(`/ ${e.registry?.description[0] ?? e.subtag}`);\n }\n }\n if (this.subtags.script) {\n parts.push(`in ${this.registry.script?.description[0] ?? this.subtags.script} script`);\n }\n if (this.subtags.region) {\n parts.push(`as spoken in ${this.registry.region?.description[0] ?? this.subtags.region}`);\n }\n if (this.registry.variants && this.registry.variants.length > 0) {\n for (const e of this.registry.variants) {\n parts.push(`(${e.registry?.description[0] ?? e.subtag})`);\n }\n }\n if (this.registry.extensions && this.registry.extensions.length > 0) {\n for (const e of this.registry.extensions) {\n parts.push(`(${e.registry?.description[0] ?? `-${e.singleton}`} \"${e.value}\")`);\n }\n }\n if (this.subtags.privateUse && this.subtags.privateUse.length > 0) {\n parts.push(`(-x \"${this.subtags.privateUse.join('-')}\")`);\n }\n } else {\n parts.push(`${this.tag} (grandfathered)`);\n }\n return parts.join(' ');\n }\n\n /**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a supplied `string` tag\n * using optional configuration, if supplied.\n * @param tag - The `string` tag from which the {@link Bcp47.LanguageTag | language tag}\n * is te be constructed.\n * @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}\n * to guide the validation and normalization of this tag.\n * @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n */\n public static createFromTag(tag: string, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n options = this._getOptions(options);\n\n return LanguageTagParser.parse(tag, options.iana).onSuccess((subtags) => {\n return this._createTransformed(subtags, 'unknown', 'unknown', options);\n });\n }\n\n /**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a supplied\n * {@link Bcp47.Subtags | subtags} using optional configuration,\n * if supplied.\n * @param tag - The {@link Bcp47.Subtags | subtags} from which the\n * {@link Bcp47.LanguageTag | language tag} is te be constructed.\n * @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}\n * to guide the validation and normalization of this tag.\n * @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n */\n public static createFromSubtags(subtags: ISubtags, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n return this._createTransformed(subtags, 'unknown', 'unknown', options);\n }\n\n /**\n * Creates a new {@link Bcp47.LanguageTag | language tag} from a supplied `string`\n * tag or {@link Bcp47.Subtags | subtags} using optional configuration,\n * if supplied.\n * @param from - The `string` tag or {@link Bcp47.Subtags | subtags} from\n * which the {@link Bcp47.LanguageTag | language tag} is te be constructed.\n * @param options - (optional) set of {@link Bcp47.ILanguageTagInitOptions | init options}\n * to guide the validation and normalization of this tag.\n * @returns `Success` with the new {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n */\n public static create(from: string | ISubtags, options?: ILanguageTagInitOptions): Result<LanguageTag> {\n if (typeof from === 'string') {\n return this.createFromTag(from, options);\n } else {\n return this.createFromSubtags(from, options);\n }\n }\n\n /**\n * Constructs a new {@link Bcp47.LanguageTag | language tag} by applying appropriate transformations\n * to as supplied {@link Bcp47.Subtags | Bcp47.Subtags}.\n * @param subtags - The {@link Bcp47.Subtags | subtags} which represent the tag.\n * @param fromValidity - The {@link Bcp47.TagValidity | validation level} of the supplied subtags.\n * @param fromNormalization - The {@link Bcp47.TagNormalization | normalization level} fo the\n * supplied subtags.\n * @param partialOptions - Any {@link Bcp47.ILanguageTagInitOptions | initialization options}.\n * @returns `Success` with the corresponding {@link Bcp47.LanguageTag | language tag} or `Failure`\n * with details if an error occurs.\n * @internal\n */\n protected static _createTransformed(\n subtags: ISubtags,\n fromValidity: TagValidity,\n fromNormalization: TagNormalization,\n partialOptions?: ILanguageTagInitOptions\n ): Result<LanguageTag> {\n const options = this._getOptions(partialOptions);\n return ValidateTag.validateSubtags(subtags, options.validity, fromValidity)\n .onSuccess(() => {\n return NormalizeTag.normalizeSubtags(subtags, options.normalization, fromNormalization);\n })\n .onSuccess((normalized) => {\n const validity = mostValid(fromValidity, options.validity);\n const normalization = mostNormalized(fromNormalization, options.normalization);\n return captureResult(() => new LanguageTag(normalized, validity, normalization, options.iana));\n });\n }\n\n /**\n * Gets a fully-specified {@link Bcp47.ILanguageTagInitOptions} from partial or undefined\n * options, substituting defaults as appropriate.\n * @param options - The {@link Bcp47.ILanguageTagInitOptions} to be expanded, or `undefined`\n * for default options.\n * @returns Fully-specified {@link Bcp47.ILanguageTagInitOptions | init options}.\n * @internal\n */\n protected static _getOptions(options?: ILanguageTagInitOptions): Required<ILanguageTagInitOptions> {\n return {\n iana: options?.iana ?? Iana.DefaultRegistries.languageRegistries,\n validity: options?.validity ?? 'well-formed',\n normalization: options?.normalization ?? 'none'\n };\n }\n\n /**\n * Returns the `Suppress-Script` value defined for the primary language of this tag,\n * regardless of whether a different script is defined in this subtag.\n * @returns The suppress-script defined for the primary language, or undefined if\n * the primary language is invalid or has no defined suppressed script.\n */\n public getSuppressedScript(): Iana.LanguageSubtags.ScriptSubtag | undefined {\n if (this._suppressedScript === undefined) {\n this._suppressedScript = false;\n if (this.subtags.primaryLanguage) {\n const language = this._iana.subtags.languages.tryGet(this.subtags.primaryLanguage);\n if (language?.suppressScript !== undefined) {\n this._suppressedScript = language.suppressScript;\n }\n }\n }\n return this._suppressedScript ? this._suppressedScript : undefined;\n }\n\n /**\n * Gets a confirmed valid representation of this language tag.\n * @returns `Success` with a valid representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be validated.\n */\n public toValid(): Result<LanguageTag> {\n if (this.isValid) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: 'valid',\n normalization: this._normalization\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a confirmed strictly valid representation of this language tag.\n * @returns `Success` with a strictly valid representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be strictly validated.\n */\n public toStrictlyValid(): Result<LanguageTag> {\n if (this.isStrictlyValid) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: 'strictly-valid',\n normalization: this._normalization\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a confirmed canonical representation of this language tag.\n * @returns `Success` with a canonical representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be normalized to canonical form.\n */\n public toCanonical(): Result<LanguageTag> {\n if (this.isCanonical) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: this._validity,\n normalization: 'canonical'\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a confirmed preferred representation of this language tag.\n * @returns `Success` with a preferred representation of this {@link Bcp47.LanguageTag | language tag},\n * or `Failure` with details if the tag cannot be normalized to preferred form.\n */\n public toPreferred(): Result<LanguageTag> {\n if (this.isPreferred) {\n return succeed(this);\n }\n const options: ILanguageTagInitOptions = {\n iana: this._iana,\n validity: 'valid', // preferred requires validity\n normalization: 'preferred'\n };\n return LanguageTag._createTransformed(this.subtags, this._validity, this._normalization, options);\n }\n\n /**\n * Gets a string representation of this language tag.\n * @returns A string representation of this language tag.\n */\n public toString(): string {\n return this.tag;\n }\n}\n"]}
|
|
@@ -21,10 +21,10 @@ export declare const isoAlpha3RegionCode: Converter<import("./model").IsoAlpha3R
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const unM49RegionCode: Converter<import("./model").UnM49RegionCode, unknown>;
|
|
23
23
|
/**
|
|
24
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
24
|
+
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
25
25
|
* containing entries of supplied template type `T`.
|
|
26
26
|
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
27
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.
|
|
27
|
+
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
30
|
export declare function datedRegistry<T, TC = unknown>(entryConverter: Converter<T, TC>): Converter<IDatedRegistry<T>, TC>;
|
|
@@ -69,10 +69,10 @@ exports.isoAlpha3RegionCode = Validate.isoAlpha3RegionCode.converter;
|
|
|
69
69
|
*/
|
|
70
70
|
exports.unM49RegionCode = Validate.unM49RegionCode.converter;
|
|
71
71
|
/**
|
|
72
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
72
|
+
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
73
73
|
* containing entries of supplied template type `T`.
|
|
74
74
|
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
75
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.
|
|
75
|
+
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
76
76
|
* @public
|
|
77
77
|
*/
|
|
78
78
|
function datedRegistry(entryConverter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../../src/packlets/iana/common/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,qDAAuC;AAEvC,4CAAsD;AAGtD;;;GAGG;AACU,QAAA,gBAAgB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC;AAErE;;;GAGG;AACU,QAAA,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC;AAE1E;;;GAGG;AACU,QAAA,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC;AAE1E;;;GAGG;AACU,QAAA,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC;AAElE;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,cAAgC;IAEhC,OAAO,qBAAU,CAAC,YAAY,CAAoB;QAChD,QAAQ,EAAE,wBAAgB;QAC1B,OAAO,EAAE,qBAAU,CAAC,OAAO,CAAC,cAAc,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC;AAPD,sCAOC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n/* eslint-disable @rushstack/typedef-var */\n\nimport * as Validate from './validate';\n\nimport { Converter, Converters } from '@fgv/ts-utils';\nimport { IDatedRegistry } from './model';\n\n/**\n * Validating converter from string {@link Iana.Model.YearMonthDaySpec}.\n * @public\n */\nexport const yearMonthDaySpec = Validate.yearMonthDateSpec.converter;\n\n/**\n * Validating converter from string {@link Iana.Model.IsoAlpha2RegionCode}.\n * @public\n */\nexport const isoAlpha2RegionCode = Validate.isoAlpha2RegionCode.converter;\n\n/**\n * Validating converter from string {@link Iana.Model.IsoAlpha3RegionCode}.\n * @public\n */\nexport const isoAlpha3RegionCode = Validate.isoAlpha3RegionCode.converter;\n\n/**\n * Validating converter from string {@link Iana.Model.UnM49RegionCode}.\n * @public\n */\nexport const unM49RegionCode = Validate.unM49RegionCode.converter;\n\n/**\n * Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
1
|
+
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../../src/packlets/iana/common/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,qDAAuC;AAEvC,4CAAsD;AAGtD;;;GAGG;AACU,QAAA,gBAAgB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC;AAErE;;;GAGG;AACU,QAAA,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC;AAE1E;;;GAGG;AACU,QAAA,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC;AAE1E;;;GAGG;AACU,QAAA,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC;AAElE;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,cAAgC;IAEhC,OAAO,qBAAU,CAAC,YAAY,CAAoB;QAChD,QAAQ,EAAE,wBAAgB;QAC1B,OAAO,EAAE,qBAAU,CAAC,OAAO,CAAC,cAAc,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC;AAPD,sCAOC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n/* eslint-disable @rushstack/typedef-var */\n\nimport * as Validate from './validate';\n\nimport { Converter, Converters } from '@fgv/ts-utils';\nimport { IDatedRegistry } from './model';\n\n/**\n * Validating converter from string {@link Iana.Model.YearMonthDaySpec}.\n * @public\n */\nexport const yearMonthDaySpec = Validate.yearMonthDateSpec.converter;\n\n/**\n * Validating converter from string {@link Iana.Model.IsoAlpha2RegionCode}.\n * @public\n */\nexport const isoAlpha2RegionCode = Validate.isoAlpha2RegionCode.converter;\n\n/**\n * Validating converter from string {@link Iana.Model.IsoAlpha3RegionCode}.\n * @public\n */\nexport const isoAlpha3RegionCode = Validate.isoAlpha3RegionCode.converter;\n\n/**\n * Validating converter from string {@link Iana.Model.UnM49RegionCode}.\n * @public\n */\nexport const unM49RegionCode = Validate.unM49RegionCode.converter;\n\n/**\n * Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}\n * containing entries of supplied template type `T`.\n * @param entryConverter - A `Converter<T>` to validate each entry\n * @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}\n * @public\n */\nexport function datedRegistry<T, TC = unknown>(\n entryConverter: Converter<T, TC>\n): Converter<IDatedRegistry<T>, TC> {\n return Converters.strictObject<IDatedRegistry<T>>({\n fileDate: yearMonthDaySpec,\n entries: Converters.arrayOf(entryConverter)\n });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { YearMonthDaySpec } from './model';
|
|
2
2
|
/**
|
|
3
|
-
* Gets the current date as an {@link Iana.YearMonthDaySpec}.
|
|
3
|
+
* Gets the current date as an {@link Iana.Model.YearMonthDaySpec | YearMonthDaySpec }.
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
export declare function nowAsYearMonthDay(): YearMonthDaySpec;
|
|
@@ -24,7 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.nowAsYearMonthDay = void 0;
|
|
25
25
|
const luxon_1 = require("luxon");
|
|
26
26
|
/**
|
|
27
|
-
* Gets the current date as an {@link Iana.YearMonthDaySpec}.
|
|
27
|
+
* Gets the current date as an {@link Iana.Model.YearMonthDaySpec | YearMonthDaySpec }.
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
30
|
function nowAsYearMonthDay() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/packlets/iana/common/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,iCAAiC;AAGjC;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,gBAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAqB,CAAC;AACnE,CAAC;AAFD,8CAEC","sourcesContent":["/*\n * Copyright (c) 2021 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DateTime } from 'luxon';\nimport { YearMonthDaySpec } from './model';\n\n/**\n * Gets the current date as an {@link Iana.YearMonthDaySpec}.\n * @public\n */\nexport function nowAsYearMonthDay(): YearMonthDaySpec {\n return DateTime.now().toFormat('yyyy-LL-dd') as YearMonthDaySpec;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/packlets/iana/common/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,iCAAiC;AAGjC;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,gBAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAqB,CAAC;AACnE,CAAC;AAFD,8CAEC","sourcesContent":["/*\n * Copyright (c) 2021 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DateTime } from 'luxon';\nimport { YearMonthDaySpec } from './model';\n\n/**\n * Gets the current date as an {@link Iana.Model.YearMonthDaySpec | YearMonthDaySpec }.\n * @public\n */\nexport function nowAsYearMonthDay(): YearMonthDaySpec {\n return DateTime.now().toFormat('yyyy-LL-dd') as YearMonthDaySpec;\n}\n"]}
|
|
@@ -7,10 +7,10 @@ import { IFileDateEntry } from './jarModel';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const fileDateEntry: Conversion.ObjectConverter<IFileDateEntry, unknown>;
|
|
9
9
|
/**
|
|
10
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
10
|
+
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
11
11
|
* containing entries of supplied template type `T`.
|
|
12
12
|
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
13
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.
|
|
13
|
+
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
export declare function datedRegistryFromJarRecords<T, TC = unknown>(entryConverter: Converter<T, TC>): Converter<IDatedRegistry<T>, TC>;
|
|
@@ -57,10 +57,10 @@ exports.fileDateEntry = ts_utils_1.Converters.strictObject({
|
|
|
57
57
|
'File-Date': CommonConverters.yearMonthDaySpec
|
|
58
58
|
});
|
|
59
59
|
/**
|
|
60
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
60
|
+
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
61
61
|
* containing entries of supplied template type `T`.
|
|
62
62
|
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
63
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.
|
|
63
|
+
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
64
64
|
* @internal
|
|
65
65
|
*/
|
|
66
66
|
function datedRegistryFromJarRecords(entryConverter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jarConverters.js","sourceRoot":"","sources":["../../../../src/packlets/iana/jar/jarConverters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,uEAAyD;AAEzD,4CAAyF;AAIzF;;;GAGG;AACU,QAAA,aAAa,GAAG,qBAAU,CAAC,YAAY,CAAiB;IACnE,gEAAgE;IAChE,WAAW,EAAE,gBAAgB,CAAC,gBAAgB;CAC/C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,cAAgC;IAEhC,OAAO,IAAI,qBAAU,CAAC,aAAa,CACjC,CAAC,IAAa,EAAE,MAAwC,EAAE,SAAc,EAA6B,EAAE;QACrG,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,OAAO,IAAA,eAAI,EAAC,6CAA6C,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,SAAS,GAAG,qBAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;YAC1B,OAAO,IAAA,eAAI,EAAC,0CAA0C,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,OAAO,GAAG,qBAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;YACxB,OAAO,IAAA,eAAI,EAAC,uCAAuC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAA,kBAAO,EAAC;YACb,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC;YACtC,OAAO,EAAE,OAAO,CAAC,KAAK;SACvB,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAxBD,kEAwBC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n/* eslint-disable @rushstack/typedef-var */\n\nimport * as CommonConverters from '../common/converters';\n\nimport { Conversion, Converter, Converters, Result, fail, succeed } from '@fgv/ts-utils';\nimport { IDatedRegistry } from '../common/model';\nimport { IFileDateEntry } from './jarModel';\n\n/**\n * Converter for the file date record found at the start of a registry file.\n * @public\n */\nexport const fileDateEntry = Converters.strictObject<IFileDateEntry>({\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 'File-Date': CommonConverters.yearMonthDaySpec\n});\n\n/**\n * Helper function which creates a converter that returns a validated {@Link Iana.Model.
|
|
1
|
+
{"version":3,"file":"jarConverters.js","sourceRoot":"","sources":["../../../../src/packlets/iana/jar/jarConverters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,uEAAyD;AAEzD,4CAAyF;AAIzF;;;GAGG;AACU,QAAA,aAAa,GAAG,qBAAU,CAAC,YAAY,CAAiB;IACnE,gEAAgE;IAChE,WAAW,EAAE,gBAAgB,CAAC,gBAAgB;CAC/C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,cAAgC;IAEhC,OAAO,IAAI,qBAAU,CAAC,aAAa,CACjC,CAAC,IAAa,EAAE,MAAwC,EAAE,SAAc,EAA6B,EAAE;QACrG,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,OAAO,IAAA,eAAI,EAAC,6CAA6C,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,SAAS,GAAG,qBAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;YAC1B,OAAO,IAAA,eAAI,EAAC,0CAA0C,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,OAAO,GAAG,qBAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;YACxB,OAAO,IAAA,eAAI,EAAC,uCAAuC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,IAAA,kBAAO,EAAC;YACb,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC;YACtC,OAAO,EAAE,OAAO,CAAC,KAAK;SACvB,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAxBD,kEAwBC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n/* eslint-disable @rushstack/typedef-var */\n\nimport * as CommonConverters from '../common/converters';\n\nimport { Conversion, Converter, Converters, Result, fail, succeed } from '@fgv/ts-utils';\nimport { IDatedRegistry } from '../common/model';\nimport { IFileDateEntry } from './jarModel';\n\n/**\n * Converter for the file date record found at the start of a registry file.\n * @public\n */\nexport const fileDateEntry = Converters.strictObject<IFileDateEntry>({\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 'File-Date': CommonConverters.yearMonthDaySpec\n});\n\n/**\n * Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}\n * containing entries of supplied template type `T`.\n * @param entryConverter - A `Converter<T>` to validate each entry\n * @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}\n * @internal\n */\nexport function datedRegistryFromJarRecords<T, TC = unknown>(\n entryConverter: Converter<T, TC>\n): Converter<IDatedRegistry<T>, TC> {\n return new Conversion.BaseConverter<IDatedRegistry<T>, TC>(\n (from: unknown, __self: Converter<IDatedRegistry<T>, TC>, __context?: TC): Result<IDatedRegistry<T>> => {\n if (typeof from === 'string' || !Array.isArray(from)) {\n return fail('JAR dated registry cannot convert non-array');\n }\n const dateEntry = fileDateEntry.convert(from[0]);\n if (dateEntry.isFailure()) {\n return fail(`Error in JAR datedRegistry date entry (${dateEntry.message})`);\n }\n\n const entries = Converters.arrayOf(entryConverter).convert(from.slice(1));\n if (entries.isFailure()) {\n return fail(`Error in JAR datedRegistry entries (${entries.message})`);\n }\n\n return succeed({\n fileDate: dateEntry.value['File-Date'],\n entries: entries.value\n });\n }\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-bcp47",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "BCP-47 Tag Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-bcp47.d.ts",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-bcp47#readme",
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@fgv/ts-utils": "
|
|
22
|
-
"@fgv/ts-utils-jest": "
|
|
23
|
-
"@fgv/ts-extras": "
|
|
24
|
-
"@fgv/ts-json-base": "
|
|
25
|
-
"@microsoft/api-documenter": "^7.
|
|
26
|
-
"@microsoft/api-extractor": "^7.
|
|
21
|
+
"@fgv/ts-utils": "4.0.0",
|
|
22
|
+
"@fgv/ts-utils-jest": "4.0.0",
|
|
23
|
+
"@fgv/ts-extras": "4.0.0",
|
|
24
|
+
"@fgv/ts-json-base": "4.0.0",
|
|
25
|
+
"@microsoft/api-documenter": "^7.24.5",
|
|
26
|
+
"@microsoft/api-extractor": "^7.43.4",
|
|
27
27
|
"@types/jest": "^29.5.12",
|
|
28
28
|
"@types/luxon": "^3.4.2",
|
|
29
|
-
"@types/node": "^20.11
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
31
|
-
"@typescript-eslint/parser": "^7.
|
|
32
|
-
"axios": "^1.6.
|
|
29
|
+
"@types/node": "^20.12.11",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
31
|
+
"@typescript-eslint/parser": "^7.9.0",
|
|
32
|
+
"axios": "^1.6.8",
|
|
33
33
|
"eslint": "^8.57.0",
|
|
34
34
|
"eslint-config-prettier": "^9.1.0",
|
|
35
35
|
"eslint-config-standard": "^17.1.0",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"eslint-plugin-promise": "^6.1.1",
|
|
40
40
|
"jest": "^29.7.0",
|
|
41
41
|
"prettier": "^3.2.5",
|
|
42
|
-
"rimraf": "^5.0.
|
|
42
|
+
"rimraf": "^5.0.7",
|
|
43
43
|
"ts-jest": "^29.1.2",
|
|
44
44
|
"ts-node": "^10.9.2",
|
|
45
|
-
"typescript": "^5.
|
|
45
|
+
"typescript": "^5.4.5",
|
|
46
46
|
"eslint-plugin-n": "^16.6.2",
|
|
47
|
-
"@rushstack/eslint-config": "~3.6.
|
|
48
|
-
"@rushstack/heft": "~0.
|
|
49
|
-
"@rushstack/heft-jest-plugin": "~0.11.
|
|
50
|
-
"@rushstack/heft-node-rig": "~2.
|
|
47
|
+
"@rushstack/eslint-config": "~3.6.9",
|
|
48
|
+
"@rushstack/heft": "~0.66.6",
|
|
49
|
+
"@rushstack/heft-jest-plugin": "~0.11.27",
|
|
50
|
+
"@rushstack/heft-node-rig": "~2.6.3",
|
|
51
51
|
"@types/heft-jest": "1.0.6",
|
|
52
52
|
"eslint-plugin-tsdoc": "~0.2.17"
|
|
53
53
|
},
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"luxon": "^3.4.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@fgv/ts-utils": "
|
|
59
|
-
"@fgv/ts-extras": "
|
|
60
|
-
"@fgv/ts-json-base": "
|
|
58
|
+
"@fgv/ts-utils": "4.0.0",
|
|
59
|
+
"@fgv/ts-extras": "4.0.0",
|
|
60
|
+
"@fgv/ts-json-base": "4.0.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "heft test --clean",
|