@fgv/ts-bcp47 5.0.0-21 → 5.0.0-23
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/package.json +8 -8
- package/src/data/bcp/overrides.json +0 -20
- package/src/data/iana/language-subtags.json +0 -57439
- package/src/data/iana/language-tag-extensions.json +0 -38
- package/src/data/unsd/m49.json +0 -3723
- package/src/index.ts +0 -29
- package/src/packlets/bcp47/bcp47Subtags/converters.ts +0 -33
- package/src/packlets/bcp47/bcp47Subtags/index.ts +0 -27
- package/src/packlets/bcp47/bcp47Subtags/model.ts +0 -46
- package/src/packlets/bcp47/bcp47Subtags/validate.ts +0 -55
- package/src/packlets/bcp47/common.ts +0 -85
- package/src/packlets/bcp47/helpers.ts +0 -117
- package/src/packlets/bcp47/index.ts +0 -38
- package/src/packlets/bcp47/languageRegistryData.ts +0 -304
- package/src/packlets/bcp47/languageTag.ts +0 -467
- package/src/packlets/bcp47/languageTagParser.ts +0 -307
- package/src/packlets/bcp47/match/chooser.ts +0 -164
- package/src/packlets/bcp47/match/common.ts +0 -57
- package/src/packlets/bcp47/match/index.ts +0 -26
- package/src/packlets/bcp47/match/similarity.ts +0 -243
- package/src/packlets/bcp47/normalization/baseNormalizer.ts +0 -146
- package/src/packlets/bcp47/normalization/canonicalNormalizer.ts +0 -102
- package/src/packlets/bcp47/normalization/common.ts +0 -84
- package/src/packlets/bcp47/normalization/index.ts +0 -27
- package/src/packlets/bcp47/normalization/normalizeTag.ts +0 -116
- package/src/packlets/bcp47/normalization/preferredTagNormalizer.ts +0 -213
- package/src/packlets/bcp47/overrides/converters.ts +0 -58
- package/src/packlets/bcp47/overrides/defaultRegistries.ts +0 -40
- package/src/packlets/bcp47/overrides/index.ts +0 -25
- package/src/packlets/bcp47/overrides/model.ts +0 -33
- package/src/packlets/bcp47/overrides/overridesRegistry.ts +0 -104
- package/src/packlets/bcp47/validation/baseValidator.ts +0 -132
- package/src/packlets/bcp47/validation/common.ts +0 -86
- package/src/packlets/bcp47/validation/index.ts +0 -29
- package/src/packlets/bcp47/validation/isCanonical.ts +0 -103
- package/src/packlets/bcp47/validation/isInPreferredForm.ts +0 -53
- package/src/packlets/bcp47/validation/isStrictlyValid.ts +0 -117
- package/src/packlets/bcp47/validation/isValid.ts +0 -122
- package/src/packlets/bcp47/validation/isWellFormed.ts +0 -102
- package/src/packlets/bcp47/validation/validateTag.ts +0 -175
- package/src/packlets/iana/common/converters.ts +0 -67
- package/src/packlets/iana/common/model.ts +0 -56
- package/src/packlets/iana/common/registeredItems.ts +0 -145
- package/src/packlets/iana/common/utils.ts +0 -32
- package/src/packlets/iana/common/validate.ts +0 -64
- package/src/packlets/iana/converters.ts +0 -26
- package/src/packlets/iana/defaultRegistries.ts +0 -40
- package/src/packlets/iana/index.ts +0 -33
- package/src/packlets/iana/jar/converters.ts +0 -26
- package/src/packlets/iana/jar/index.ts +0 -27
- package/src/packlets/iana/jar/jarConverters.ts +0 -70
- package/src/packlets/iana/jar/jarModel.ts +0 -34
- package/src/packlets/iana/jar/language-subtags/converters.ts +0 -26
- package/src/packlets/iana/jar/language-subtags/index.ts +0 -27
- package/src/packlets/iana/jar/language-subtags/model.ts +0 -26
- package/src/packlets/iana/jar/language-subtags/registry/converters.ts +0 -40
- package/src/packlets/iana/jar/language-subtags/registry/index.ts +0 -26
- package/src/packlets/iana/jar/language-subtags/registry/model.ts +0 -171
- package/src/packlets/iana/jar/language-subtags/tags/converters.ts +0 -120
- package/src/packlets/iana/jar/language-subtags/tags/index.ts +0 -28
- package/src/packlets/iana/jar/language-subtags/tags/model.ts +0 -71
- package/src/packlets/iana/jar/language-subtags/tags/tagValidation.ts +0 -67
- package/src/packlets/iana/jar/language-subtags/tags/validate.ts +0 -106
- package/src/packlets/iana/jar/model.ts +0 -26
- package/src/packlets/iana/language-subtags/common.ts +0 -46
- package/src/packlets/iana/language-subtags/converters.ts +0 -226
- package/src/packlets/iana/language-subtags/index.ts +0 -30
- package/src/packlets/iana/language-subtags/jarConverters.ts +0 -269
- package/src/packlets/iana/language-subtags/model.ts +0 -213
- package/src/packlets/iana/language-subtags/scope.ts +0 -222
- package/src/packlets/iana/language-subtags/subtagRegistry.ts +0 -136
- package/src/packlets/iana/language-subtags/validate.ts +0 -23
- package/src/packlets/iana/language-tag-extensions/converters.ts +0 -71
- package/src/packlets/iana/language-tag-extensions/extensionsRegistry.ts +0 -92
- package/src/packlets/iana/language-tag-extensions/extensionsScope.ts +0 -60
- package/src/packlets/iana/language-tag-extensions/index.ts +0 -29
- package/src/packlets/iana/language-tag-extensions/jarConverters.ts +0 -91
- package/src/packlets/iana/language-tag-extensions/model.ts +0 -67
- package/src/packlets/iana/language-tag-extensions/validate.ts +0 -36
- package/src/packlets/iana/languageRegistries.ts +0 -57
- package/src/packlets/iana/model.ts +0 -26
- package/src/packlets/iana/validate.ts +0 -23
- package/src/packlets/unsd/areas.ts +0 -105
- package/src/packlets/unsd/common.ts +0 -79
- package/src/packlets/unsd/csv/converters.ts +0 -82
- package/src/packlets/unsd/csv/index.ts +0 -26
- package/src/packlets/unsd/csv/model.ts +0 -44
- package/src/packlets/unsd/defaultRegistries.ts +0 -40
- package/src/packlets/unsd/index.ts +0 -28
- package/src/packlets/unsd/regionCodes.ts +0 -144
- package/src/packlets/unsd/regions.ts +0 -95
- package/src/packlets/utils/index.ts +0 -24
- package/src/packlets/utils/jsonHelpers.ts +0 -25
- package/src/packlets/utils/public.ts +0 -28
- package/src/packlets/utils/validationHelpers.ts +0 -180
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { LanguageRegistries } from './languageRegistries';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export class DefaultRegistries {
|
|
29
|
-
/**
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
protected static _languageRegistries?: LanguageRegistries = undefined;
|
|
33
|
-
|
|
34
|
-
public static get languageRegistries(): LanguageRegistries {
|
|
35
|
-
if (!this._languageRegistries) {
|
|
36
|
-
this._languageRegistries = LanguageRegistries.loadDefault().orThrow();
|
|
37
|
-
}
|
|
38
|
-
return this._languageRegistries;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { nowAsYearMonthDay } from './common/utils';
|
|
24
|
-
import * as Converters from './converters';
|
|
25
|
-
import * as Jar from './jar';
|
|
26
|
-
import * as LanguageSubtags from './language-subtags';
|
|
27
|
-
import * as LanguageTagExtensions from './language-tag-extensions';
|
|
28
|
-
import * as Model from './model';
|
|
29
|
-
import * as Validate from './validate';
|
|
30
|
-
|
|
31
|
-
export { DefaultRegistries } from './defaultRegistries';
|
|
32
|
-
export * from './languageRegistries';
|
|
33
|
-
export { Converters, Jar, Model, LanguageSubtags, LanguageTagExtensions, Validate, nowAsYearMonthDay };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export * from './jarConverters';
|
|
24
|
-
|
|
25
|
-
import * as LanguageSubtags from './language-subtags/tags/converters';
|
|
26
|
-
export { LanguageSubtags };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import * as Converters from './converters';
|
|
24
|
-
import * as LanguageSubtags from './language-subtags';
|
|
25
|
-
import * as Model from './model';
|
|
26
|
-
|
|
27
|
-
export { Converters, LanguageSubtags, Model };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
/* eslint-disable @rushstack/typedef-var */
|
|
23
|
-
|
|
24
|
-
import * as CommonConverters from '../common/converters';
|
|
25
|
-
|
|
26
|
-
import { Conversion, Converter, Converters, Result, fail, succeed } from '@fgv/ts-utils';
|
|
27
|
-
import { IDatedRegistry } from '../common/model';
|
|
28
|
-
import { IFileDateEntry } from './jarModel';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Converter for the file date record found at the start of a registry file.
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export const fileDateEntry = Converters.strictObject<IFileDateEntry>({
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
36
|
-
'File-Date': CommonConverters.yearMonthDaySpec
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Helper function which creates a converter that returns a validated {@Link Iana.Model.IDatedRegistry | DatedRegistry}
|
|
41
|
-
* containing entries of supplied template type `T`.
|
|
42
|
-
* @param entryConverter - A `Converter<T>` to validate each entry
|
|
43
|
-
* @returns A new validating `Converter` which yields {@Link Iana.Model.IDatedRegistry | DatedRegistry<T>}
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export function datedRegistryFromJarRecords<T, TC = unknown>(
|
|
47
|
-
entryConverter: Converter<T, TC>
|
|
48
|
-
): Converter<IDatedRegistry<T>, TC> {
|
|
49
|
-
return new Conversion.BaseConverter<IDatedRegistry<T>, TC>(
|
|
50
|
-
(from: unknown, __self: Converter<IDatedRegistry<T>, TC>, __context?: TC): Result<IDatedRegistry<T>> => {
|
|
51
|
-
if (typeof from === 'string' || !Array.isArray(from)) {
|
|
52
|
-
return fail('JAR dated registry cannot convert non-array');
|
|
53
|
-
}
|
|
54
|
-
const dateEntry = fileDateEntry.convert(from[0]);
|
|
55
|
-
if (dateEntry.isFailure()) {
|
|
56
|
-
return fail(`Error in JAR datedRegistry date entry (${dateEntry.message})`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const entries = Converters.arrayOf(entryConverter).convert(from.slice(1));
|
|
60
|
-
if (entries.isFailure()) {
|
|
61
|
-
return fail(`Error in JAR datedRegistry entries (${entries.message})`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return succeed({
|
|
65
|
-
fileDate: dateEntry.value['File-Date'],
|
|
66
|
-
entries: entries.value
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { RecordJar } from '@fgv/ts-extras';
|
|
24
|
-
import { YearMonthDaySpec } from '../common/model';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* File date record entry typically placed at the head of a registry
|
|
28
|
-
* file.
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export interface IFileDateEntry extends RecordJar.JarRecord {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
33
|
-
'File-Date': YearMonthDaySpec;
|
|
34
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import * as Registry from './registry/converters';
|
|
24
|
-
import * as Tags from './tags/converters';
|
|
25
|
-
|
|
26
|
-
export { Registry, Tags };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import * as Converters from './converters';
|
|
24
|
-
import * as Tags from './tags';
|
|
25
|
-
|
|
26
|
-
export * from './model';
|
|
27
|
-
export { Converters, Tags };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import * as Registry from './registry/model';
|
|
24
|
-
import * as Tags from './tags/model';
|
|
25
|
-
|
|
26
|
-
export { Registry, Tags };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
/* eslint-disable @rushstack/typedef-var */
|
|
23
|
-
|
|
24
|
-
import * as Model from './model';
|
|
25
|
-
|
|
26
|
-
import { Converters } from '@fgv/ts-utils';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export const registryEntryType = Converters.enumeratedValue<Model.RegistryEntryType>(
|
|
32
|
-
Model.allRegistryEntryTypes
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
export const registryScopeType = Converters.enumeratedValue<Model.RegistryEntryScope>(
|
|
39
|
-
Model.allRegistryEntryScopes
|
|
40
|
-
);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
// istanbul ignore file
|
|
23
|
-
export * from './model';
|
|
24
|
-
|
|
25
|
-
import * as Converters from './converters';
|
|
26
|
-
export { Converters };
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
ExtLangSubtag,
|
|
25
|
-
GrandfatheredTag,
|
|
26
|
-
LanguageSubtag,
|
|
27
|
-
RedundantTag,
|
|
28
|
-
RegionSubtag,
|
|
29
|
-
ScriptSubtag,
|
|
30
|
-
VariantSubtag
|
|
31
|
-
} from '../tags/model';
|
|
32
|
-
|
|
33
|
-
import { Brand } from '@fgv/ts-utils';
|
|
34
|
-
import { IDatedRegistry } from '../../../common/model';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
export type RegistryEntryType =
|
|
40
|
-
| 'extlang'
|
|
41
|
-
| 'grandfathered'
|
|
42
|
-
| 'language'
|
|
43
|
-
| 'redundant'
|
|
44
|
-
| 'region'
|
|
45
|
-
| 'script'
|
|
46
|
-
| 'variant';
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
51
|
-
export const allRegistryEntryTypes: RegistryEntryType[] = [
|
|
52
|
-
'extlang',
|
|
53
|
-
'grandfathered',
|
|
54
|
-
'language',
|
|
55
|
-
'redundant',
|
|
56
|
-
'region',
|
|
57
|
-
'script',
|
|
58
|
-
'variant'
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
export type RegistryEntryScope = 'collection' | 'macrolanguage' | 'private-use' | 'special';
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @internal
|
|
68
|
-
*/
|
|
69
|
-
export const allRegistryEntryScopes: RegistryEntryScope[] = [
|
|
70
|
-
'collection',
|
|
71
|
-
'macrolanguage',
|
|
72
|
-
'private-use',
|
|
73
|
-
'special'
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
79
|
-
export type YearMonthDaySpec = Brand<string, 'YearMonthDaySpec'>;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @internal
|
|
83
|
-
*/
|
|
84
|
-
interface IRegistryEntryBase<TTYPE extends RegistryEntryType = RegistryEntryType> {
|
|
85
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
86
|
-
Type: TTYPE;
|
|
87
|
-
Description: string[];
|
|
88
|
-
Added: YearMonthDaySpec;
|
|
89
|
-
Deprecated?: YearMonthDaySpec;
|
|
90
|
-
'Suppress-Script'?: ScriptSubtag;
|
|
91
|
-
Macrolanguage?: LanguageSubtag;
|
|
92
|
-
'Preferred-Value'?: string;
|
|
93
|
-
Prefix?: string[];
|
|
94
|
-
Scope?: RegistryEntryScope;
|
|
95
|
-
Comments?: string[];
|
|
96
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @internal
|
|
101
|
-
*/
|
|
102
|
-
export interface IRegistrySubtagEntry<
|
|
103
|
-
TTYPE extends RegistryEntryType = RegistryEntryType,
|
|
104
|
-
TSUBTAG extends string = string
|
|
105
|
-
> extends IRegistryEntryBase<TTYPE> {
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
107
|
-
Subtag: TSUBTAG | TSUBTAG[];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @internal
|
|
112
|
-
*/
|
|
113
|
-
export interface IRegistryTagEntry<
|
|
114
|
-
TTYPE extends RegistryEntryType = RegistryEntryType,
|
|
115
|
-
TTAG extends string = string
|
|
116
|
-
> extends IRegistryEntryBase<TTYPE> {
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
118
|
-
Tag: TTAG | TTAG[];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @internal
|
|
123
|
-
*/
|
|
124
|
-
export type LanguageSubtagRegistryEntry = IRegistrySubtagEntry<'language', LanguageSubtag>;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
export type ExtLangSubtagRegistryEntry = IRegistrySubtagEntry<'extlang', ExtLangSubtag>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
export type ScriptSubtagRegistryEntry = IRegistrySubtagEntry<'script', ScriptSubtag>;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @internal
|
|
138
|
-
*/
|
|
139
|
-
export type RegionSubtagRegistryEntry = IRegistrySubtagEntry<'region', RegionSubtag>;
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* @internal
|
|
143
|
-
*/
|
|
144
|
-
export type VariantSubtagRegistryEntry = IRegistrySubtagEntry<'variant', VariantSubtag>;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @internal
|
|
148
|
-
*/
|
|
149
|
-
export type GrandfatheredTagRegistryEntry = IRegistryTagEntry<'grandfathered', GrandfatheredTag>;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* @internal
|
|
153
|
-
*/
|
|
154
|
-
export type RedundantTagRegistryEntry = IRegistryTagEntry<'redundant', RedundantTag>;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* @internal
|
|
158
|
-
*/
|
|
159
|
-
export type RegistryEntry =
|
|
160
|
-
| LanguageSubtagRegistryEntry
|
|
161
|
-
| ExtLangSubtagRegistryEntry
|
|
162
|
-
| ScriptSubtagRegistryEntry
|
|
163
|
-
| RegionSubtagRegistryEntry
|
|
164
|
-
| VariantSubtagRegistryEntry
|
|
165
|
-
| GrandfatheredTagRegistryEntry
|
|
166
|
-
| RedundantTagRegistryEntry;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
export type RegistryFile = IDatedRegistry<RegistryEntry>;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 Erik Fortune
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
* copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
/* eslint-disable @rushstack/typedef-var */
|
|
23
|
-
|
|
24
|
-
import * as Validate from './validate';
|
|
25
|
-
|
|
26
|
-
import { Conversion, Converter, Converters, Result, fail, mapResults, succeed } from '@fgv/ts-utils';
|
|
27
|
-
|
|
28
|
-
import { LanguageSubtag } from './model';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
export const languageSubtag = Validate.languageSubtag.converter;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export const extlangSubtag = Validate.extlangSubtag.converter;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export const scriptSubtag = Validate.scriptSubtag.converter;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export const regionSubtag = Validate.regionSubtag.converter;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export const variantSubtag = Validate.variantSubtag.converter;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export const grandfatheredTag = Validate.grandfatheredTag.converter;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
|
-
export const redundantTag = Validate.redundantTag.converter;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @public
|
|
67
|
-
*/
|
|
68
|
-
export const extendedLanguageRange = Validate.extendedLanguageRange.converter;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
export function rangeOfTags<TTAG extends string>(tagConverter: Converter<TTAG>): Converter<TTAG[]> {
|
|
74
|
-
return new Conversion.BaseConverter<TTAG[]>((from: unknown): Result<TTAG[]> => {
|
|
75
|
-
if (typeof from !== 'string') {
|
|
76
|
-
return fail('tagRange converter: not a string');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const elements = from.split('..');
|
|
80
|
-
if (elements.length !== 2 || elements[0] === '' || elements[1] === '') {
|
|
81
|
-
return fail(`"${from}: malformed tag range`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return mapResults(elements.map((tag) => tagConverter.convert(tag)));
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
export function tagOrRange<TTAG extends string>(tagConverter: Converter<TTAG>): Converter<TTAG | TTAG[]> {
|
|
92
|
-
return Converters.oneOf<TTAG | TTAG[]>([tagConverter, rangeOfTags(tagConverter)]);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
export function tagOrStartOfTagRange<TTAG extends string>(tagConverter: Converter<TTAG>): Converter<TTAG> {
|
|
99
|
-
return tagOrRange(tagConverter).map((t) => (Array.isArray(t) ? succeed(t[0]) : succeed(t)));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
export function endOfTagRangeOrUndefined<TTAG extends string>(
|
|
106
|
-
tagConverter: Converter<TTAG>
|
|
107
|
-
): Converter<TTAG | undefined> {
|
|
108
|
-
return tagOrRange(tagConverter).map((t) => (Array.isArray(t) ? succeed(t[1]) : succeed(undefined)));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @internal
|
|
113
|
-
*/
|
|
114
|
-
export const extlangPrefix = Converters.arrayOf(languageSubtag).map((tags) => {
|
|
115
|
-
/* c8 ignore next 3 - defense in depth */
|
|
116
|
-
if (tags.length !== 1) {
|
|
117
|
-
return fail<LanguageSubtag>(`[${tags.join(', ')}]: malformed extlang prefix`);
|
|
118
|
-
}
|
|
119
|
-
return succeed(tags[0]);
|
|
120
|
-
});
|