@fgv/ts-bcp47 5.1.0-2 → 5.1.0-4
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/dist/data/bcp/overrides.json +21 -0
- package/dist/data/unsd/m49.json +3723 -0
- package/dist/index.browser.js +30 -0
- package/dist/index.js +28 -0
- package/dist/packlets/bcp47/bcp47Subtags/converters.js +32 -0
- package/dist/packlets/bcp47/bcp47Subtags/index.js +26 -0
- package/dist/packlets/bcp47/bcp47Subtags/model.js +23 -0
- package/dist/packlets/bcp47/bcp47Subtags/validate.js +48 -0
- package/dist/packlets/bcp47/common.js +53 -0
- package/dist/packlets/bcp47/helpers.js +96 -0
- package/dist/packlets/bcp47/index.js +32 -0
- package/dist/packlets/bcp47/languageRegistryData.js +202 -0
- package/dist/packlets/bcp47/languageTag.js +363 -0
- package/dist/packlets/bcp47/languageTagParser.js +275 -0
- package/dist/packlets/bcp47/match/chooser.js +88 -0
- package/dist/packlets/bcp47/match/common.js +49 -0
- package/dist/packlets/bcp47/match/index.js +26 -0
- package/dist/packlets/bcp47/match/similarity.js +205 -0
- package/dist/packlets/bcp47/normalization/baseNormalizer.js +89 -0
- package/dist/packlets/bcp47/normalization/canonicalNormalizer.js +86 -0
- package/dist/packlets/bcp47/normalization/common.js +77 -0
- package/dist/packlets/bcp47/normalization/index.js +27 -0
- package/dist/packlets/bcp47/normalization/normalizeTag.js +101 -0
- package/dist/packlets/bcp47/normalization/preferredTagNormalizer.js +177 -0
- package/dist/packlets/bcp47/overrides/converters.js +49 -0
- package/dist/packlets/bcp47/overrides/defaultRegistries.js +38 -0
- package/dist/packlets/bcp47/overrides/index.js +25 -0
- package/dist/packlets/bcp47/overrides/model.js +23 -0
- package/dist/packlets/bcp47/overrides/overridesRegistry.js +83 -0
- package/dist/packlets/bcp47/validation/baseValidator.js +86 -0
- package/dist/packlets/bcp47/validation/common.js +77 -0
- package/dist/packlets/bcp47/validation/index.js +29 -0
- package/dist/packlets/bcp47/validation/isCanonical.js +79 -0
- package/dist/packlets/bcp47/validation/isInPreferredForm.js +46 -0
- package/dist/packlets/bcp47/validation/isStrictlyValid.js +94 -0
- package/dist/packlets/bcp47/validation/isValid.js +92 -0
- package/dist/packlets/bcp47/validation/isWellFormed.js +75 -0
- package/dist/packlets/bcp47/validation/validateTag.js +153 -0
- package/dist/packlets/iana/common/converters.js +58 -0
- package/dist/packlets/iana/common/model.js +23 -0
- package/dist/packlets/iana/common/registeredItems.js +120 -0
- package/dist/packlets/iana/common/utils.js +30 -0
- package/dist/packlets/iana/common/validate.js +59 -0
- package/dist/packlets/iana/converters.js +25 -0
- package/dist/packlets/iana/defaultRegistries.js +38 -0
- package/dist/packlets/iana/iana-data-embedded.js +60 -0
- package/dist/packlets/iana/index.browser.js +34 -0
- package/dist/packlets/iana/index.js +34 -0
- package/dist/packlets/iana/jar/converters.js +25 -0
- package/dist/packlets/iana/jar/index.js +26 -0
- package/dist/packlets/iana/jar/jarConverters.js +60 -0
- package/dist/packlets/iana/jar/jarModel.js +23 -0
- package/dist/packlets/iana/jar/language-subtags/converters.js +25 -0
- package/dist/packlets/iana/jar/language-subtags/index.js +26 -0
- package/dist/packlets/iana/jar/language-subtags/model.js +25 -0
- package/dist/packlets/iana/jar/language-subtags/registry/converters.js +180 -0
- package/dist/packlets/iana/jar/language-subtags/registry/index.js +26 -0
- package/dist/packlets/iana/jar/language-subtags/registry/model.js +43 -0
- package/dist/packlets/iana/jar/language-subtags/tags/converters.js +101 -0
- package/dist/packlets/iana/jar/language-subtags/tags/index.js +27 -0
- package/dist/packlets/iana/jar/language-subtags/tags/model.js +23 -0
- package/dist/packlets/iana/jar/language-subtags/tags/tagValidation.js +66 -0
- package/dist/packlets/iana/jar/language-subtags/tags/validate.js +85 -0
- package/dist/packlets/iana/jar/model.js +25 -0
- package/dist/packlets/iana/language-subtags/common.js +23 -0
- package/dist/packlets/iana/language-subtags/converters.js +182 -0
- package/dist/packlets/iana/language-subtags/index.browser.js +30 -0
- package/dist/packlets/iana/language-subtags/index.js +29 -0
- package/dist/packlets/iana/language-subtags/jarConverters.js +288 -0
- package/dist/packlets/iana/language-subtags/model.js +23 -0
- package/dist/packlets/iana/language-subtags/scope.js +169 -0
- package/dist/packlets/iana/language-subtags/subtagRegistry.js +108 -0
- package/dist/packlets/iana/language-subtags/validate.js +23 -0
- package/dist/packlets/iana/language-tag-extensions/converters.js +59 -0
- package/dist/packlets/iana/language-tag-extensions/extensionsRegistry.js +64 -0
- package/dist/packlets/iana/language-tag-extensions/extensionsScope.js +50 -0
- package/dist/packlets/iana/language-tag-extensions/index.js +28 -0
- package/dist/packlets/iana/language-tag-extensions/jarConverters.js +143 -0
- package/dist/packlets/iana/language-tag-extensions/model.js +24 -0
- package/dist/packlets/iana/language-tag-extensions/validate.js +33 -0
- package/dist/packlets/iana/languageRegistries.js +80 -0
- package/dist/packlets/iana/languageRegistriesFileLoader.js +73 -0
- package/dist/packlets/iana/languageRegistriesLoader.js +113 -0
- package/dist/packlets/iana/model.js +25 -0
- package/dist/packlets/iana/validate.js +23 -0
- package/dist/packlets/unsd/areas.js +92 -0
- package/dist/packlets/unsd/common.js +23 -0
- package/dist/packlets/unsd/csv/converters.js +75 -0
- package/dist/packlets/unsd/csv/index.js +25 -0
- package/dist/packlets/unsd/csv/model.js +23 -0
- package/dist/packlets/unsd/defaultRegistries.js +38 -0
- package/dist/packlets/unsd/index.js +27 -0
- package/dist/packlets/unsd/regionCodes.js +115 -0
- package/dist/packlets/unsd/regions.js +71 -0
- package/dist/packlets/utils/index.js +24 -0
- package/dist/packlets/utils/jsonHelpers.js +25 -0
- package/dist/packlets/utils/public.js +24 -0
- package/dist/packlets/utils/validationHelpers.js +116 -0
- package/dist/test/unit/bcp47/commonTestCases.js +475 -0
- package/dist/test/unit/bcp47/languageTagHelpers.js +178 -0
- package/dist/test/unit/iana/testConstants.js +68 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +36 -31
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import * as Registry from './registry/converters';
|
|
23
|
+
import * as Tags from './tags/converters';
|
|
24
|
+
export { Registry, Tags };
|
|
25
|
+
//# sourceMappingURL=converters.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import * as Converters from './converters';
|
|
23
|
+
import * as Tags from './tags';
|
|
24
|
+
export * from './model';
|
|
25
|
+
export { Converters, Tags };
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import * as Registry from './registry/model';
|
|
23
|
+
import * as Tags from './tags/model';
|
|
24
|
+
export { Registry, Tags };
|
|
25
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
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
|
+
import * as Model from './model';
|
|
24
|
+
import * as TagConverters from '../tags/converters';
|
|
25
|
+
import { Converters } from '@fgv/ts-utils';
|
|
26
|
+
import { yearMonthDaySpec } from '../../../common/converters';
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export const registryEntryType = Converters.enumeratedValue(Model.allRegistryEntryTypes);
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export const registryScopeType = Converters.enumeratedValue(Model.allRegistryEntryScopes);
|
|
35
|
+
/**
|
|
36
|
+
* JAR format converter for language subtag entries (preserves hyphenated field names)
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export const jarLanguageSubtagEntry = Converters.transformObject({
|
|
40
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['language']) },
|
|
41
|
+
Subtag: { from: 'Subtag', converter: TagConverters.tagOrRange(TagConverters.languageSubtag) },
|
|
42
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
43
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
44
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
45
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
46
|
+
Macrolanguage: { from: 'Macrolanguage', converter: TagConverters.languageSubtag, optional: true },
|
|
47
|
+
'Preferred-Value': { from: 'Preferred-Value', converter: TagConverters.languageSubtag, optional: true },
|
|
48
|
+
Scope: { from: 'Scope', converter: registryScopeType, optional: true },
|
|
49
|
+
'Suppress-Script': { from: 'Suppress-Script', converter: TagConverters.scriptSubtag, optional: true }
|
|
50
|
+
}, {
|
|
51
|
+
strict: true,
|
|
52
|
+
description: 'JAR language subtag entry'
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* JAR format converter for extlang subtag entries
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export const jarExtLangSubtagEntry = Converters.transformObject({
|
|
59
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['extlang']) },
|
|
60
|
+
Subtag: { from: 'Subtag', converter: TagConverters.extlangSubtag },
|
|
61
|
+
'Preferred-Value': { from: 'Preferred-Value', converter: TagConverters.extendedLanguageRange },
|
|
62
|
+
Prefix: { from: 'Prefix', converter: Converters.arrayOf(TagConverters.languageSubtag) },
|
|
63
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
64
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
65
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
66
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
67
|
+
Macrolanguage: { from: 'Macrolanguage', converter: TagConverters.languageSubtag, optional: true },
|
|
68
|
+
Scope: { from: 'Scope', converter: registryScopeType, optional: true },
|
|
69
|
+
'Suppress-Script': { from: 'Suppress-Script', converter: TagConverters.scriptSubtag, optional: true }
|
|
70
|
+
}, {
|
|
71
|
+
strict: true,
|
|
72
|
+
description: 'JAR extlang subtag entry'
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* JAR format converter for script subtag entries
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
export const jarScriptSubtagEntry = Converters.transformObject({
|
|
79
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['script']) },
|
|
80
|
+
Subtag: { from: 'Subtag', converter: TagConverters.tagOrRange(TagConverters.scriptSubtag) },
|
|
81
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
82
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
83
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
84
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
85
|
+
'Preferred-Value': { from: 'Preferred-Value', converter: TagConverters.scriptSubtag, optional: true }
|
|
86
|
+
}, {
|
|
87
|
+
strict: true,
|
|
88
|
+
description: 'JAR script subtag entry'
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* JAR format converter for region subtag entries
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export const jarRegionSubtagEntry = Converters.transformObject({
|
|
95
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['region']) },
|
|
96
|
+
Subtag: { from: 'Subtag', converter: TagConverters.tagOrRange(TagConverters.regionSubtag) },
|
|
97
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
98
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
99
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
100
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
101
|
+
'Preferred-Value': { from: 'Preferred-Value', converter: TagConverters.regionSubtag, optional: true }
|
|
102
|
+
}, {
|
|
103
|
+
strict: true,
|
|
104
|
+
description: 'JAR region subtag entry'
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* JAR format converter for variant subtag entries
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
export const jarVariantSubtagEntry = Converters.transformObject({
|
|
111
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['variant']) },
|
|
112
|
+
Subtag: { from: 'Subtag', converter: TagConverters.variantSubtag },
|
|
113
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
114
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
115
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
116
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
117
|
+
'Preferred-Value': { from: 'Preferred-Value', converter: TagConverters.variantSubtag, optional: true },
|
|
118
|
+
Prefix: {
|
|
119
|
+
from: 'Prefix',
|
|
120
|
+
converter: Converters.arrayOf(TagConverters.extendedLanguageRange),
|
|
121
|
+
optional: true
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
strict: true,
|
|
125
|
+
description: 'JAR variant subtag entry'
|
|
126
|
+
});
|
|
127
|
+
/**
|
|
128
|
+
* JAR format converter for grandfathered tag entries
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
export const jarGrandfatheredTagEntry = Converters.transformObject({
|
|
132
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['grandfathered']) },
|
|
133
|
+
Tag: { from: 'Tag', converter: TagConverters.grandfatheredTag },
|
|
134
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
135
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
136
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
137
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
138
|
+
'Preferred-Value': {
|
|
139
|
+
from: 'Preferred-Value',
|
|
140
|
+
converter: TagConverters.extendedLanguageRange,
|
|
141
|
+
optional: true
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
strict: true,
|
|
145
|
+
description: 'JAR grandfathered tag entry'
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* JAR format converter for redundant tag entries
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
export const jarRedundantTagEntry = Converters.transformObject({
|
|
152
|
+
Type: { from: 'Type', converter: Converters.enumeratedValue(['redundant']) },
|
|
153
|
+
Tag: { from: 'Tag', converter: TagConverters.redundantTag },
|
|
154
|
+
Description: { from: 'Description', converter: Converters.stringArray },
|
|
155
|
+
Added: { from: 'Added', converter: yearMonthDaySpec },
|
|
156
|
+
Comments: { from: 'Comments', converter: Converters.stringArray, optional: true },
|
|
157
|
+
Deprecated: { from: 'Deprecated', converter: yearMonthDaySpec, optional: true },
|
|
158
|
+
'Preferred-Value': {
|
|
159
|
+
from: 'Preferred-Value',
|
|
160
|
+
converter: TagConverters.extendedLanguageRange,
|
|
161
|
+
optional: true
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
strict: true,
|
|
165
|
+
description: 'JAR redundant tag entry'
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* JAR format discriminated converter for all registry entries
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
export const jarRegistryEntry = Converters.discriminatedObject('Type', {
|
|
172
|
+
language: jarLanguageSubtagEntry,
|
|
173
|
+
extlang: jarExtLangSubtagEntry,
|
|
174
|
+
script: jarScriptSubtagEntry,
|
|
175
|
+
region: jarRegionSubtagEntry,
|
|
176
|
+
variant: jarVariantSubtagEntry,
|
|
177
|
+
grandfathered: jarGrandfatheredTagEntry,
|
|
178
|
+
redundant: jarRedundantTagEntry
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=converters.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import * as Converters from './converters';
|
|
25
|
+
export { Converters };
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export const allRegistryEntryTypes = [
|
|
26
|
+
'extlang',
|
|
27
|
+
'grandfathered',
|
|
28
|
+
'language',
|
|
29
|
+
'redundant',
|
|
30
|
+
'region',
|
|
31
|
+
'script',
|
|
32
|
+
'variant'
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export const allRegistryEntryScopes = [
|
|
38
|
+
'collection',
|
|
39
|
+
'macrolanguage',
|
|
40
|
+
'private-use',
|
|
41
|
+
'special'
|
|
42
|
+
];
|
|
43
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
import * as Validate from './validate';
|
|
24
|
+
import { Conversion, Converters, fail, mapResults, succeed } from '@fgv/ts-utils';
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export const languageSubtag = Validate.languageSubtag.converter;
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export const extlangSubtag = Validate.extlangSubtag.converter;
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export const scriptSubtag = Validate.scriptSubtag.converter;
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export const regionSubtag = Validate.regionSubtag.converter;
|
|
41
|
+
/**
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export const variantSubtag = Validate.variantSubtag.converter;
|
|
45
|
+
/**
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export const grandfatheredTag = Validate.grandfatheredTag.converter;
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export const redundantTag = Validate.redundantTag.converter;
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export const extendedLanguageRange = Validate.extendedLanguageRange.converter;
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export function rangeOfTags(tagConverter) {
|
|
61
|
+
return new Conversion.BaseConverter((from) => {
|
|
62
|
+
if (typeof from !== 'string') {
|
|
63
|
+
return fail('tagRange converter: not a string');
|
|
64
|
+
}
|
|
65
|
+
const elements = from.split('..');
|
|
66
|
+
if (elements.length !== 2 || elements[0] === '' || elements[1] === '') {
|
|
67
|
+
return fail(`"${from}: malformed tag range`);
|
|
68
|
+
}
|
|
69
|
+
return mapResults(elements.map((tag) => tagConverter.convert(tag)));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export function tagOrRange(tagConverter) {
|
|
76
|
+
return Converters.oneOf([tagConverter, rangeOfTags(tagConverter)]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export function tagOrStartOfTagRange(tagConverter) {
|
|
82
|
+
/* c8 ignore next 1 - tested but coverage intermittently missed */
|
|
83
|
+
return tagOrRange(tagConverter).map((t) => (Array.isArray(t) ? succeed(t[0]) : succeed(t)));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
export function endOfTagRangeOrUndefined(tagConverter) {
|
|
89
|
+
return tagOrRange(tagConverter).map((t) => (Array.isArray(t) ? succeed(t[1]) : succeed(undefined)));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export const extlangPrefix = Converters.arrayOf(languageSubtag).map((tags) => {
|
|
95
|
+
/* c8 ignore next 3 - defense in depth */
|
|
96
|
+
if (tags.length !== 1) {
|
|
97
|
+
return fail(`[${tags.join(', ')}]: malformed extlang prefix`);
|
|
98
|
+
}
|
|
99
|
+
return succeed(tags[0]);
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=converters.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
import * as Converters from './converters';
|
|
23
|
+
import * as Helpers from './tagValidation';
|
|
24
|
+
import * as Validators from './validate';
|
|
25
|
+
export * from './model';
|
|
26
|
+
export { Converters, Helpers, Validators };
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021 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
|
+
import { succeed } from '@fgv/ts-utils';
|
|
23
|
+
import { ValidationHelpers } from '../../../../utils';
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export class TagValidationHelpers extends ValidationHelpers {
|
|
28
|
+
constructor(description) {
|
|
29
|
+
super({
|
|
30
|
+
description,
|
|
31
|
+
toCanonical: TagValidationHelpers.toCanonicalTag,
|
|
32
|
+
isWellFormed: (from) => {
|
|
33
|
+
return typeof from === 'string' && this.wellFormed.test(from);
|
|
34
|
+
},
|
|
35
|
+
isCanonical: (from) => {
|
|
36
|
+
if (this.isWellFormed(from)) {
|
|
37
|
+
const result = this.toCanonical(from);
|
|
38
|
+
if (result.isSuccess()) {
|
|
39
|
+
return result.value === from;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this.wellFormed = /^([A-Za-z][A-Za-z0-9-]{0,7})(-[A-Za-z][A-Za-z0-9-]{0,7})*$/;
|
|
46
|
+
}
|
|
47
|
+
static toCanonicalTag(val) {
|
|
48
|
+
const subtags = val.split('-');
|
|
49
|
+
const canonical = [];
|
|
50
|
+
let isInitial = true;
|
|
51
|
+
for (const part of subtags) {
|
|
52
|
+
if (isInitial || (part.length !== 2 && part.length !== 4)) {
|
|
53
|
+
canonical.push(part.toLowerCase());
|
|
54
|
+
}
|
|
55
|
+
else if (part.length === 2) {
|
|
56
|
+
canonical.push(part.toUpperCase());
|
|
57
|
+
}
|
|
58
|
+
else if (part.length === 4) {
|
|
59
|
+
canonical.push(`${part[0].toUpperCase()}${part.slice(1).toLowerCase()}`);
|
|
60
|
+
}
|
|
61
|
+
isInitial = part.length === 1;
|
|
62
|
+
}
|
|
63
|
+
return succeed(canonical.join('-'));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=tagValidation.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021 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
|
+
import { succeed } from '@fgv/ts-utils';
|
|
24
|
+
import { RegExpValidationHelpers } from '../../../../utils';
|
|
25
|
+
import { TagValidationHelpers } from './tagValidation';
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export const languageSubtag = new RegExpValidationHelpers({
|
|
30
|
+
description: 'language subtag',
|
|
31
|
+
wellFormed: /^[A-Za-z]{2,3}$/,
|
|
32
|
+
canonical: /^[a-z]{2,3}$/,
|
|
33
|
+
toCanonical: (from) => succeed(from.toLowerCase())
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export const extlangSubtag = new RegExpValidationHelpers({
|
|
39
|
+
description: 'extlang subtag',
|
|
40
|
+
wellFormed: /^[A-Za-z]{3}$/,
|
|
41
|
+
canonical: /^[a-z]{3}$/,
|
|
42
|
+
toCanonical: (from) => succeed(from.toLowerCase())
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export const scriptSubtag = new RegExpValidationHelpers({
|
|
48
|
+
description: 'script subtag',
|
|
49
|
+
wellFormed: /^[A-Za-z]{4}$/,
|
|
50
|
+
canonical: /^[A-Z][a-z]{3}$/,
|
|
51
|
+
toCanonical: (from) => {
|
|
52
|
+
return succeed(`${from[0].toUpperCase()}${from.slice(1).toLowerCase()}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export const regionSubtag = new RegExpValidationHelpers({
|
|
59
|
+
description: 'region subtag',
|
|
60
|
+
wellFormed: /^([A-Za-z]{2,3})$|^([0-9]{3})$/,
|
|
61
|
+
canonical: /^([A-Z]{2,3})$|^([0-9]{3})$/,
|
|
62
|
+
toCanonical: (from) => succeed(from.toUpperCase())
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export const variantSubtag = new RegExpValidationHelpers({
|
|
68
|
+
description: 'variant subtag',
|
|
69
|
+
wellFormed: /^([A-Za-z0-9]{5,8})$|^([0-9][A-Za-z0-9]{3})$/,
|
|
70
|
+
canonical: /^([a-z0-9]{5,8})$|^([0-9][a-z0-9]{3})$/,
|
|
71
|
+
toCanonical: (from) => succeed(from.toLowerCase())
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export const grandfatheredTag = new TagValidationHelpers('grandfathered tag');
|
|
77
|
+
/**
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export const redundantTag = new TagValidationHelpers('redundant tag');
|
|
81
|
+
/**
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export const extendedLanguageRange = new TagValidationHelpers('extended language range');
|
|
85
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
export * from './jarModel';
|
|
23
|
+
import * as LanguageSubtags from './language-subtags/model';
|
|
24
|
+
export { LanguageSubtags };
|
|
25
|
+
//# sourceMappingURL=model.js.map
|