Skip to content

Commit f80e027

Browse files
feat: Intl.Collator
1 parent 1b1472c commit f80e027

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

src/intl/Core__Intl__Collator.res

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,61 @@
11
type t
22

3+
type usage = [#sort | #search]
4+
type sensitivity = [#base | #accent | #case | #variant]
5+
type caseFirst = [#upper | #lower | #"false"]
6+
type collation = [
7+
| #big5han // (Chinese; do not use; not available in Firefox, Chrome or Edge)
8+
| #compat // (Arabic)
9+
| #dict // (Sinhala)
10+
| #direct // (deprecated, do not use)
11+
| #ducet // (not available, do not use)
12+
| #emoji // (root)
13+
| #eor // (root)
14+
| #gb2312 // (Chinese; do not use; not available in Chrome or Edge)
15+
| #phonebk // (German)
16+
| #phonetic // (Lingala)
17+
| #pinyin // (Chinese)
18+
| #reformed // (formerly Swedish; do not specify explicitly as this was the old name for the default for Swedish)
19+
| #searchjl // (Korean; do not use as this is for searching rather than sorting, and the API covers only sorting)
20+
| #stroke // (Chinese)
21+
| #trad
22+
| #unihan // (Chinese, Japanese, and Korean; not available in Chrome or Edge)
23+
| #zhuyin
24+
] // (Chinese)
25+
26+
type options = {
27+
localeMatcher?: Core__Intl__Common.localeMatcher,
28+
usage?: usage,
29+
sensitivity?: sensitivity,
30+
ignorePunctuation?: bool,
31+
numeric?: bool,
32+
caseFirst?: caseFirst,
33+
}
34+
35+
type resolvedOptions = {
36+
locale: string,
37+
usage: usage,
38+
sensitivity: sensitivity,
39+
ignorePunctuation: bool,
40+
collation: [collation | #default],
41+
numeric?: bool,
42+
caseFirst?: caseFirst,
43+
}
44+
45+
type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher}
46+
347
@new external make: unit => t = "Intl.Collator"
448
@new external makeWithLocale: string => t = "Intl.Collator"
549
@new external makeWithLocales: array<string> => t = "Intl.Collator"
6-
@new external makeWithLocaleAndOptions: (string, {..}) => t = "Intl.Collator"
7-
@new external makeWithLocalesAndOptions: (array<string>, {..}) => t = "Intl.Collator"
8-
@new external makeWithOptions: (@as(json`undefined`) _, {..}) => t = "Intl.Collator"
50+
@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Collator"
51+
@new external makeWithLocalesAndOptions: (array<string>, options) => t = "Intl.Collator"
52+
@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Collator"
953

1054
@val external supportedLocalesOf: array<string> => t = "Intl.Collator.supportedLocalesOf"
1155
@val
12-
external supportedLocalesOfWithOptions: (array<string>, {..}) => t =
56+
external supportedLocalesOfWithOptions: (array<string>, supportedLocalesOptions) => t =
1357
"Intl.Collator.supportedLocalesOf"
1458

15-
@send external resolvedOptions: t => {..} = "resolvedOptions"
59+
@send external resolvedOptions: t => resolvedOptions = "resolvedOptions"
1660

1761
@send external compare: (t, string, string) => int = "compare"

0 commit comments

Comments
 (0)