Skip to content

Commit 3a8757f

Browse files
committed
Simplify constructors for Intl types
1 parent 248cfc5 commit 3a8757f

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

src/intl/Core__Intl__Collator.res

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,10 @@ type resolvedOptions = {
2525

2626
type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher}
2727

28-
@new external make: unit => t = "Intl.Collator"
29-
@new external makeWithLocale: string => t = "Intl.Collator"
30-
@new external makeWithLocales: array<string> => t = "Intl.Collator"
31-
@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Collator"
32-
@new external makeWithLocalesAndOptions: (array<string>, options) => t = "Intl.Collator"
33-
@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Collator"
34-
35-
@val external supportedLocalesOf: array<string> => t = "Intl.Collator.supportedLocalesOf"
28+
@new external make: (~locales: array<string>=?, ~options: options=?) => t = "Intl.Collator"
29+
3630
@val
37-
external supportedLocalesOfWithOptions: (array<string>, supportedLocalesOptions) => t =
31+
external supportedLocalesOf: (array<string>, ~options: supportedLocalesOptions=?) => t =
3832
"Intl.Collator.supportedLocalesOf"
3933

4034
@send external resolvedOptions: t => resolvedOptions = "resolvedOptions"

test/intl/Intl__CollatorTest.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ console.log("---");
55

66
console.log("Intl.Collator");
77

8-
new Intl.Collator();
8+
new Intl.Collator(undefined, undefined);
99

10-
new Intl.Collator("en-US");
10+
new Intl.Collator(["en-US"], undefined);
1111

1212
var _collator = new Intl.Collator([
1313
"en-US",
1414
"en-GB"
15-
]);
15+
], undefined);
1616

17-
var collator = new Intl.Collator("en-US", {
17+
var collator = new Intl.Collator(["en-US"], {
1818
sensitivity: "base",
1919
ignorePunctuation: true,
2020
numeric: true,
@@ -24,7 +24,7 @@ var collator = new Intl.Collator("en-US", {
2424
Intl.Collator.supportedLocalesOf([
2525
"en-US",
2626
"en-GB"
27-
]);
27+
], undefined);
2828

2929
Intl.Collator.supportedLocalesOf([
3030
"en-US",
@@ -37,7 +37,7 @@ console.log(collator.resolvedOptions());
3737

3838
console.log(collator.compare("hi", "hï"));
3939

40-
console.log(Intl.Collator.supportedLocalesOf(["hi"]));
40+
console.log(Intl.Collator.supportedLocalesOf(["hi"], undefined));
4141

4242
export {
4343
_collator ,

test/intl/Intl__CollatorTest.res

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ Console.log("---")
44
Console.log("Intl.Collator")
55

66
let _collator = Intl.Collator.make()
7-
let _collator = Intl.Collator.makeWithLocale("en-US")
8-
let _collator = Intl.Collator.makeWithLocales(["en-US", "en-GB"])
9-
let collator = Intl.Collator.makeWithLocaleAndOptions(
10-
"en-US",
11-
{caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true},
7+
let _collator = Intl.Collator.make(~locales=["en-US"])
8+
let _collator = Intl.Collator.make(~locales=["en-US", "en-GB"])
9+
let collator = Intl.Collator.make(
10+
~locales=["en-US"],
11+
~options={caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true},
1212
)
1313
Intl.Collator.supportedLocalesOf(["en-US", "en-GB"])->ignore
14-
Intl.Collator.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore
14+
Intl.Collator.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore
1515

1616
collator->Intl.Collator.resolvedOptions->Console.log
1717
collator->Intl.Collator.compare("hi", "hï")->Console.log

0 commit comments

Comments
 (0)