diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ebee649..e263572a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next version +- BREAKING: Intl types: simplify bindings for constructors / functions with optional arguments. https://github.com/rescript-association/rescript-core/pull/198 - Fix: Expose Intl.Common. https://github.com/rescript-association/rescript-core/pull/197 ## 1.1.0 diff --git a/src/intl/Core__Intl__Collator.res b/src/intl/Core__Intl__Collator.res index 300b8766..a6271c57 100644 --- a/src/intl/Core__Intl__Collator.res +++ b/src/intl/Core__Intl__Collator.res @@ -25,16 +25,10 @@ type resolvedOptions = { type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.Collator" -@new external makeWithLocale: string => t = "Intl.Collator" -@new external makeWithLocales: array => t = "Intl.Collator" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Collator" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.Collator" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Collator" - -@val external supportedLocalesOf: array => t = "Intl.Collator.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.Collator" + @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.Collator.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__DateTimeFormat.res b/src/intl/Core__Intl__DateTimeFormat.res index 009445e3..1ec24b29 100644 --- a/src/intl/Core__Intl__DateTimeFormat.res +++ b/src/intl/Core__Intl__DateTimeFormat.res @@ -105,16 +105,10 @@ type dateTimeRangePart = { source: dateTimeRangeSource, } -@new external make: unit => t = "Intl.DateTimeFormat" -@new external makeWithLocale: string => t = "Intl.DateTimeFormat" -@new external makeWithLocales: array => t = "Intl.DateTimeFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.DateTimeFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.DateTimeFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.DateTimeFormat" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.DateTimeFormat" -@val external supportedLocalesOf: array => t = "Intl.DateTimeFormat.supportedLocalesOf" @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.DateTimeFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__ListFormat.res b/src/intl/Core__Intl__ListFormat.res index 43a6174a..ba728899 100644 --- a/src/intl/Core__Intl__ListFormat.res +++ b/src/intl/Core__Intl__ListFormat.res @@ -35,16 +35,10 @@ type resolvedOptions = { type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.ListFormat" -@new external makeWithLocale: string => t = "Intl.ListFormat" -@new external makeWithLocales: array => t = "Intl.ListFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.ListFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.ListFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.ListFormat" - -@val external supportedLocalesOf: array => t = "Intl.ListFormat.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.ListFormat" + @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.ListFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__Locale.res b/src/intl/Core__Intl__Locale.res index 5d6afb47..07d32332 100644 --- a/src/intl/Core__Intl__Locale.res +++ b/src/intl/Core__Intl__Locale.res @@ -13,8 +13,7 @@ type options = { region?: string, } -@new external make: string => t = "Intl.Locale" -@new external makeWithOptions: (string, options) => t = "Intl.Locale" +@new external make: (string, ~options: options=?) => t = "Intl.Locale" @get external baseName: t => string = "baseName" @get external calendar: t => option = "calendar" diff --git a/src/intl/Core__Intl__NumberFormat.res b/src/intl/Core__Intl__NumberFormat.res index f229a3f5..3929e8cf 100644 --- a/src/intl/Core__Intl__NumberFormat.res +++ b/src/intl/Core__Intl__NumberFormat.res @@ -166,17 +166,10 @@ type numberFormatRangePart = { source: rangeSource, } -@new external make: unit => t = "Intl.NumberFormat" -@new external makeWithLocale: string => t = "Intl.NumberFormat" -@new external makeWithLocales: array => t = "Intl.NumberFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.NumberFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.NumberFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.NumberFormat" - -@val external supportedLocalesOf: array => t = "Intl.NumberFormat.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.NumberFormat" @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.NumberFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__PluralRules.res b/src/intl/Core__Intl__PluralRules.res index 008f5ab3..7831df0a 100644 --- a/src/intl/Core__Intl__PluralRules.res +++ b/src/intl/Core__Intl__PluralRules.res @@ -38,16 +38,10 @@ type resolvedOptions = { type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.PluralRules" -@new external makeWithLocale: string => t = "Intl.PluralRules" -@new external makeWithLocales: array => t = "Intl.PluralRules" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.PluralRules" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.PluralRules" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.PluralRules" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.PluralRules" -@val external supportedLocalesOf: array => t = "Intl.PluralRules.supportedLocalesOf" @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.PluralRules.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__RelativeTimeFormat.res b/src/intl/Core__Intl__RelativeTimeFormat.res index 8cbf2138..97849049 100644 --- a/src/intl/Core__Intl__RelativeTimeFormat.res +++ b/src/intl/Core__Intl__RelativeTimeFormat.res @@ -26,17 +26,11 @@ type relativeTimePart = { unit?: timeUnit, } -@new external make: unit => t = "Intl.RelativeTimeFormat" -@new external makeWithLocale: string => t = "Intl.RelativeTimeFormat" -@new external makeWithLocales: array => t = "Intl.RelativeTimeFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.RelativeTimeFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.RelativeTimeFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.RelativeTimeFormat" +@new +external make: (~locales: array=?, ~options: options=?) => t = "Intl.RelativeTimeFormat" @val -external supportedLocalesOf: array => t = "Intl.RelativeTimeFormat.supportedLocalesOf" -@val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.RelativeTimeFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__Segmenter.res b/src/intl/Core__Intl__Segmenter.res index c6def395..e99b576d 100644 --- a/src/intl/Core__Intl__Segmenter.res +++ b/src/intl/Core__Intl__Segmenter.res @@ -23,16 +23,10 @@ type resolvedOptions = {locale: string, granularity: granularity} type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.Segmenter" -@new external makeWithLocale: string => t = "Intl.Segmenter" -@new external makeWithLocales: array => t = "Intl.Segmenter" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Segmenter" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.Segmenter" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Segmenter" - -@val external supportedLocalesOf: array => t = "Intl.Segmenter.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.Segmenter" + @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.Segmenter.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/test/Intl/IntlTests.mjs b/test/Intl/IntlTests.mjs deleted file mode 100644 index 6fcf5875..00000000 --- a/test/Intl/IntlTests.mjs +++ /dev/null @@ -1,134 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Js_exn from "rescript/lib/es6/js_exn.js"; -import * as Caml_option from "rescript/lib/es6/caml_option.js"; -import * as Core__Option from "../../src/Core__Option.mjs"; -import * as Intl__LocaleTest from "./Intl__LocaleTest.mjs"; -import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; -import * as Intl__CollatorTest from "./Intl__CollatorTest.mjs"; -import * as Intl__SegmenterTest from "./Intl__SegmenterTest.mjs"; -import * as Intl__ListFormatTest from "./Intl__ListFormatTest.mjs"; -import * as Intl__PluralRulesTest from "./Intl__PluralRulesTest.mjs"; -import * as Intl__NumberFormatTest from "./Intl__NumberFormatTest.mjs"; -import * as Intl__DateTimeFormatTest from "./Intl__DateTimeFormatTest.mjs"; -import * as Intl__RelativeTimeFormatTest from "./Intl__RelativeTimeFormatTest.mjs"; - -console.log("---"); - -console.log("Intl"); - -console.log(Intl.getCanonicalLocales("EN-US")); - -console.log(Intl.getCanonicalLocales([ - "EN-US", - "Fr" - ])); - -try { - console.log(Intl.getCanonicalLocales("bloop")); -} -catch (raw_e){ - var e = Caml_js_exceptions.internalToOCamlException(raw_e); - if (e.RE_EXN_ID === Js_exn.$$Error) { - console.error(e._1); - } else { - throw e; - } -} - -try { - console.log(Intl.supportedValuesOf("calendar")); - console.log(Intl.supportedValuesOf("collation")); - console.log(Intl.supportedValuesOf("currency")); - console.log(Intl.supportedValuesOf("numberingSystem")); - console.log(Intl.supportedValuesOf("timeZone")); - console.log(Intl.supportedValuesOf("unit")); -} -catch (raw_e$1){ - var e$1 = Caml_js_exceptions.internalToOCamlException(raw_e$1); - if (e$1.RE_EXN_ID === Js_exn.$$Error) { - console.error(e$1._1); - } else { - throw e$1; - } -} - -try { - Intl.supportedValuesOf("someInvalidKey"); - console.error("Shouldn't have been hit"); -} -catch (raw_e$2){ - var e$2 = Caml_js_exceptions.internalToOCamlException(raw_e$2); - if (e$2.RE_EXN_ID === Js_exn.$$Error) { - var e$3 = e$2._1; - var message = Core__Option.map(e$3.message, (function (prim) { - return prim.toLowerCase(); - })); - var exit = 0; - if (message === "invalid key : someinvalidkey") { - console.log("Caught expected error"); - } else { - exit = 1; - } - if (exit === 1) { - console.warn("Unexpected error message: \"" + message + "\""); - throw e$3; - } - - } else { - var e$4 = Caml_js_exceptions.as_js_exn(e$2); - if (e$4 !== undefined) { - throw Caml_option.valFromOption(e$4); - } - console.error("Unexpected error"); - } -} - -var _collator = Intl__CollatorTest._collator; - -var collator = Intl__CollatorTest.collator; - -var resolvedOptions = Intl__DateTimeFormatTest.resolvedOptions; - -var timeZone = Intl__DateTimeFormatTest.timeZone; - -var _locale = Intl__LocaleTest._locale; - -var locale = Intl__LocaleTest.locale; - -var currencyFormatter = Intl__NumberFormatTest.currencyFormatter; - -var roundingFormatter = Intl__NumberFormatTest.roundingFormatter; - -var groupingFormatter1 = Intl__NumberFormatTest.groupingFormatter1; - -var groupingFormatter2 = Intl__NumberFormatTest.groupingFormatter2; - -var sigFormatter = Intl__NumberFormatTest.sigFormatter; - -var options = Intl__NumberFormatTest.options; - -var _formatter = Intl__SegmenterTest._formatter; - -var formatter = Intl__SegmenterTest.formatter; - -var segments = Intl__SegmenterTest.segments; - -export { - _collator , - collator , - resolvedOptions , - timeZone , - _locale , - locale , - currencyFormatter , - roundingFormatter , - groupingFormatter1 , - groupingFormatter2 , - sigFormatter , - options , - _formatter , - formatter , - segments , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__CollatorTest.mjs b/test/Intl/Intl__CollatorTest.mjs deleted file mode 100644 index 3945f3a8..00000000 --- a/test/Intl/Intl__CollatorTest.mjs +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -console.log("---"); - -console.log("Intl.Collator"); - -new Intl.Collator(); - -new Intl.Collator("en-US"); - -var _collator = new Intl.Collator([ - "en-US", - "en-GB" - ]); - -var collator = new Intl.Collator("en-US", { - sensitivity: "base", - ignorePunctuation: true, - numeric: true, - caseFirst: "upper" - }); - -Intl.Collator.supportedLocalesOf([ - "en-US", - "en-GB" - ]); - -Intl.Collator.supportedLocalesOf([ - "en-US", - "en-GB" - ], { - localeMatcher: "lookup" - }); - -console.log(collator.resolvedOptions()); - -console.log(collator.compare("hi", "hï")); - -console.log(Intl.Collator.supportedLocalesOf(["hi"])); - -export { - _collator , - collator , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__DateTimeFormatTest.mjs b/test/Intl/Intl__DateTimeFormatTest.mjs deleted file mode 100644 index 140ae17c..00000000 --- a/test/Intl/Intl__DateTimeFormatTest.mjs +++ /dev/null @@ -1,90 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; - -console.log("---"); - -console.log("Intl.DateTimeFormat"); - -Intl.DateTimeFormat.supportedLocalesOf([ - "en-US", - "en-GB" - ]); - -Intl.DateTimeFormat.supportedLocalesOf([ - "en-US", - "en-GB" - ], { - localeMatcher: "lookup" - }); - -var formatter = new Intl.DateTimeFormat(undefined, { - dateStyle: "full", - timeStyle: "full" - }); - -console.log(formatter.format(new Date(Date.now()))); - -console.log(formatter.formatRange(new Date(2023, 1, 1), new Date(2023, 12, 31))); - -var options = { - timeZone: "UTC", - hour12: false, - hourCycle: "h24", - weekday: "narrow", - era: "narrow", - year: "2-digit", - month: "2-digit", - day: "2-digit", - hour: "2-digit", - minute: "2-digit", - second: "2-digit", - fractionalSecondDigits: 3, - timeZoneName: "longGeneric" -}; - -var formatter$1 = new Intl.DateTimeFormat(undefined, options); - -console.log(formatter$1.format(new Date(Date.now()))); - -var newrecord = Caml_obj.obj_dup(options); - -var formatter$2 = new Intl.DateTimeFormat(undefined, (newrecord.timeZoneName = "long", newrecord)); - -console.log(formatter$2.format(new Date(Date.now()))); - -var newrecord$1 = Caml_obj.obj_dup(options); - -var formatter$3 = new Intl.DateTimeFormat(undefined, (newrecord$1.timeZoneName = "longOffset", newrecord$1)); - -console.log(formatter$3.format(new Date(Date.now()))); - -var newrecord$2 = Caml_obj.obj_dup(options); - -var formatter$4 = new Intl.DateTimeFormat(undefined, (newrecord$2.timeZoneName = "short", newrecord$2)); - -console.log(formatter$4.format(new Date(Date.now()))); - -var newrecord$3 = Caml_obj.obj_dup(options); - -var formatter$5 = new Intl.DateTimeFormat(undefined, (newrecord$3.timeZoneName = "shortGeneric", newrecord$3)); - -console.log(formatter$5.format(new Date(Date.now()))); - -var newrecord$4 = Caml_obj.obj_dup(options); - -var formatter$6 = new Intl.DateTimeFormat(undefined, (newrecord$4.timeZoneName = "shortOffset", newrecord$4)); - -console.log(formatter$6.format(new Date(Date.now()))); - -var resolvedOptions = new Intl.DateTimeFormat().resolvedOptions(); - -var timeZone = resolvedOptions.timeZone; - -export { - options , - formatter$6 as formatter, - resolvedOptions , - timeZone , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__ListFormatTest.mjs b/test/Intl/Intl__ListFormatTest.mjs deleted file mode 100644 index 592a5eb7..00000000 --- a/test/Intl/Intl__ListFormatTest.mjs +++ /dev/null @@ -1,65 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -console.log("---"); - -console.log("Intl.ListFormat"); - -new Intl.ListFormat(); - -new Intl.ListFormat("en-US"); - -new Intl.ListFormat([ - "en-US", - "en-GB" - ]); - -new Intl.ListFormat("en-US", { - type: "conjunction", - style: "long" - }); - -var _formatter = new Intl.ListFormat([ - "en-US", - "en-GB" - ], { - type: "conjunction", - style: "long" - }); - -Intl.ListFormat.supportedLocalesOf([ - "en-US", - "en-GB" - ]); - -Intl.ListFormat.supportedLocalesOf([ - "en-US", - "en-GB" - ], { - localeMatcher: "lookup" - }); - -var formatter = new Intl.ListFormat(undefined, { - type: "conjunction", - style: "long" - }); - -console.log(formatter.resolvedOptions()); - -console.log(formatter.format([ - "one", - "two", - "three" - ])); - -console.log(formatter.formatToParts([ - "one", - "two", - "three" - ])); - -export { - _formatter , - formatter , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__LocaleTest.mjs b/test/Intl/Intl__LocaleTest.mjs deleted file mode 100644 index a8349a84..00000000 --- a/test/Intl/Intl__LocaleTest.mjs +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -console.log("---"); - -console.log("Intl.Locale"); - -var _locale = new Intl.Locale("en-US"); - -var locale = new Intl.Locale("en-US", { - calendar: "hebrew", - collation: "compat", - hourCycle: "h24", - caseFirst: "upper", - numeric: true - }); - -console.log(locale.baseName); - -console.log(locale.calendar); - -console.log(locale.caseFirst); - -console.log(locale.collation); - -console.log(locale.hourCycle); - -console.log(locale.language); - -console.log(locale.numberingSystem); - -console.log(locale.numeric); - -console.log(locale.region); - -console.log(locale.script); - -console.log(locale.maximize()); - -console.log(locale.minimize()); - -export { - _locale , - locale , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__NumberFormatTest.mjs b/test/Intl/Intl__NumberFormatTest.mjs deleted file mode 100644 index d19804e9..00000000 --- a/test/Intl/Intl__NumberFormatTest.mjs +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Caml_option from "rescript/lib/es6/caml_option.js"; -import * as Core__Intl__NumberFormat__Grouping from "../../src/intl/Core__Intl__NumberFormat__Grouping.mjs"; - -console.log("---"); - -console.log("Intl.NumberFormat"); - -var currencyFormatter = new Intl.NumberFormat("fr-FR", { - currency: "EUR", - style: "currency" - }); - -console.log(Intl.NumberFormat.supportedLocalesOf([ - "fr-FR", - "en-US" - ])); - -console.log(currencyFormatter.format(123.23)); - -var roundingFormatter = new Intl.NumberFormat(undefined, { - roundingIncrement: 500, - minimumFractionDigits: 2, - maximumFractionDigits: 2 - }); - -var groupingFormatter1 = new Intl.NumberFormat(undefined, { - useGrouping: Caml_option.some(true) - }); - -var groupingFormatter2 = new Intl.NumberFormat(undefined, { - useGrouping: "auto" - }); - -var sigFormatter = new Intl.NumberFormat(undefined, { - minimumIntegerDigits: 1, - minimumFractionDigits: 1, - maximumFractionDigits: 1, - minimumSignificantDigits: 1, - maximumSignificantDigits: 1 - }); - -var options = sigFormatter.resolvedOptions(); - -console.log(options); - -console.log(Core__Intl__NumberFormat__Grouping.parseJsValue(options.useGrouping)); - -export { - currencyFormatter , - roundingFormatter , - groupingFormatter1 , - groupingFormatter2 , - sigFormatter , - options , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__PluralRulesTest.mjs b/test/Intl/Intl__PluralRulesTest.mjs deleted file mode 100644 index b4fe8030..00000000 --- a/test/Intl/Intl__PluralRulesTest.mjs +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -console.log("---"); - -console.log("Intl.PluralRules"); - -new Intl.PluralRules(); - -new Intl.PluralRules("en-US"); - -new Intl.PluralRules([ - "en-US", - "en-GB" - ]); - -new Intl.PluralRules(undefined, { - type: "ordinal", - minimumSignificantDigits: 3, - maximumSignificantDigits: 5 - }); - -var _formatter = new Intl.PluralRules("en-US", { - type: "ordinal", - minimumSignificantDigits: 3, - maximumSignificantDigits: 5 - }); - -var formatter = new Intl.PluralRules(["en-US"], { - type: "ordinal", - minimumSignificantDigits: 3, - maximumSignificantDigits: 5 - }); - -console.log(formatter.resolvedOptions()); - -console.log(formatter.select(2.0)); - -console.log(formatter.select(2)); - -export { - _formatter , - formatter , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__RelativeTimeFormatTest.mjs b/test/Intl/Intl__RelativeTimeFormatTest.mjs deleted file mode 100644 index 062d89be..00000000 --- a/test/Intl/Intl__RelativeTimeFormatTest.mjs +++ /dev/null @@ -1,54 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -console.log("---"); - -console.log("Intl.RelativeTimeFormat"); - -Intl.RelativeTimeFormat.supportedLocalesOf([ - "en-US", - "en-GB" - ]); - -Intl.RelativeTimeFormat.supportedLocalesOf([ - "en-US", - "en-GB" - ], { - localeMatcher: "lookup" - }); - -new Intl.RelativeTimeFormat(); - -new Intl.RelativeTimeFormat("en-US"); - -new Intl.RelativeTimeFormat([ - "en-US", - "en-GB" - ]); - -new Intl.RelativeTimeFormat(undefined, { - numeric: "always", - style: "narrow" - }); - -var _formatter = new Intl.RelativeTimeFormat("en-US", { - numeric: "always", - style: "narrow" - }); - -var formatter = new Intl.RelativeTimeFormat(["en-US"], { - numeric: "always", - style: "narrow" - }); - -console.log(formatter.resolvedOptions()); - -console.log(formatter.format(3, "hour")); - -console.log(formatter.formatToParts(3, "hour")); - -export { - _formatter , - formatter , -} -/* Not a pure module */ diff --git a/test/Intl/Intl__SegmenterTest.mjs b/test/Intl/Intl__SegmenterTest.mjs deleted file mode 100644 index 757c7c4d..00000000 --- a/test/Intl/Intl__SegmenterTest.mjs +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -console.log("---"); - -console.log("Intl.Segmenter"); - -Intl.Segmenter.supportedLocalesOf([ - "en-US", - "en-GB" - ]); - -Intl.Segmenter.supportedLocalesOf([ - "en-US", - "en-GB" - ], { - localeMatcher: "lookup" - }); - -new Intl.Segmenter(); - -new Intl.Segmenter("en-US"); - -new Intl.Segmenter([ - "en-US", - "en-GB" - ]); - -new Intl.Segmenter(undefined, { - granularity: "word" - }); - -var _formatter = new Intl.Segmenter("en-US", { - granularity: "word" - }); - -var formatter = new Intl.Segmenter(["en-US"], { - granularity: "word" - }); - -console.log(formatter.resolvedOptions()); - -var segments = formatter.segment("This is a sentence with several words"); - -console.log(segments); - -console.log(segments.containing()); - -console.log(segments.containing(1)); - -export { - _formatter , - formatter , - segments , -} -/* Not a pure module */ diff --git a/test/intl/Intl__CollatorTest.mjs b/test/intl/Intl__CollatorTest.mjs index 3945f3a8..a42c8e08 100644 --- a/test/intl/Intl__CollatorTest.mjs +++ b/test/intl/Intl__CollatorTest.mjs @@ -5,16 +5,16 @@ console.log("---"); console.log("Intl.Collator"); -new Intl.Collator(); +new Intl.Collator(undefined, undefined); -new Intl.Collator("en-US"); +new Intl.Collator(["en-US"], undefined); var _collator = new Intl.Collator([ "en-US", "en-GB" - ]); + ], undefined); -var collator = new Intl.Collator("en-US", { +var collator = new Intl.Collator(["en-US"], { sensitivity: "base", ignorePunctuation: true, numeric: true, @@ -24,7 +24,7 @@ var collator = new Intl.Collator("en-US", { Intl.Collator.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.Collator.supportedLocalesOf([ "en-US", @@ -37,7 +37,7 @@ console.log(collator.resolvedOptions()); console.log(collator.compare("hi", "hï")); -console.log(Intl.Collator.supportedLocalesOf(["hi"])); +console.log(Intl.Collator.supportedLocalesOf(["hi"], undefined)); export { _collator , diff --git a/test/intl/Intl__CollatorTest.res b/test/intl/Intl__CollatorTest.res index 45ea8d7b..abba374f 100644 --- a/test/intl/Intl__CollatorTest.res +++ b/test/intl/Intl__CollatorTest.res @@ -4,14 +4,14 @@ Console.log("---") Console.log("Intl.Collator") let _collator = Intl.Collator.make() -let _collator = Intl.Collator.makeWithLocale("en-US") -let _collator = Intl.Collator.makeWithLocales(["en-US", "en-GB"]) -let collator = Intl.Collator.makeWithLocaleAndOptions( - "en-US", - {caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true}, +let _collator = Intl.Collator.make(~locales=["en-US"]) +let _collator = Intl.Collator.make(~locales=["en-US", "en-GB"]) +let collator = Intl.Collator.make( + ~locales=["en-US"], + ~options={caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true}, ) Intl.Collator.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.Collator.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore +Intl.Collator.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore collator->Intl.Collator.resolvedOptions->Console.log collator->Intl.Collator.compare("hi", "hï")->Console.log diff --git a/test/intl/Intl__DateTimeFormatTest.mjs b/test/intl/Intl__DateTimeFormatTest.mjs index 140ae17c..62e31e91 100644 --- a/test/intl/Intl__DateTimeFormatTest.mjs +++ b/test/intl/Intl__DateTimeFormatTest.mjs @@ -9,7 +9,7 @@ console.log("Intl.DateTimeFormat"); Intl.DateTimeFormat.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.DateTimeFormat.supportedLocalesOf([ "en-US", @@ -77,7 +77,7 @@ var formatter$6 = new Intl.DateTimeFormat(undefined, (newrecord$4.timeZoneName = console.log(formatter$6.format(new Date(Date.now()))); -var resolvedOptions = new Intl.DateTimeFormat().resolvedOptions(); +var resolvedOptions = new Intl.DateTimeFormat(undefined, undefined).resolvedOptions(); var timeZone = resolvedOptions.timeZone; diff --git a/test/intl/Intl__DateTimeFormatTest.res b/test/intl/Intl__DateTimeFormatTest.res index f98b75c1..20e77d58 100644 --- a/test/intl/Intl__DateTimeFormatTest.res +++ b/test/intl/Intl__DateTimeFormatTest.res @@ -4,12 +4,12 @@ Console.log("---") Console.log("Intl.DateTimeFormat") Intl.DateTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.DateTimeFormat.supportedLocalesOfWithOptions( +Intl.DateTimeFormat.supportedLocalesOf( ["en-US", "en-GB"], - {localeMatcher: #lookup}, + ~options={localeMatcher: #lookup}, )->ignore -let formatter = Intl.DateTimeFormat.makeWithOptions({dateStyle: #full, timeStyle: #full}) +let formatter = Intl.DateTimeFormat.make(~options={dateStyle: #full, timeStyle: #full}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) @@ -35,23 +35,23 @@ let options: Intl.DateTimeFormat.options = { fractionalSecondDigits: #3, timeZoneName: #longGeneric, } -let formatter = Intl.DateTimeFormat.makeWithOptions(options) +let formatter = Intl.DateTimeFormat.make(~options) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #long}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #long}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #longOffset}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #longOffset}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #short}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #short}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #shortGeneric}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #shortGeneric}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #shortOffset}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #shortOffset}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) let resolvedOptions = Intl.DateTimeFormat.make()->Intl.DateTimeFormat.resolvedOptions diff --git a/test/intl/Intl__ListFormatTest.mjs b/test/intl/Intl__ListFormatTest.mjs index 592a5eb7..f4bb15e8 100644 --- a/test/intl/Intl__ListFormatTest.mjs +++ b/test/intl/Intl__ListFormatTest.mjs @@ -5,19 +5,12 @@ console.log("---"); console.log("Intl.ListFormat"); -new Intl.ListFormat(); - -new Intl.ListFormat("en-US"); +new Intl.ListFormat(undefined, undefined); new Intl.ListFormat([ "en-US", "en-GB" - ]); - -new Intl.ListFormat("en-US", { - type: "conjunction", - style: "long" - }); + ], undefined); var _formatter = new Intl.ListFormat([ "en-US", @@ -30,7 +23,7 @@ var _formatter = new Intl.ListFormat([ Intl.ListFormat.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.ListFormat.supportedLocalesOf([ "en-US", diff --git a/test/intl/Intl__ListFormatTest.res b/test/intl/Intl__ListFormatTest.res index 8bb9a479..ec5fae7d 100644 --- a/test/intl/Intl__ListFormatTest.res +++ b/test/intl/Intl__ListFormatTest.res @@ -4,20 +4,15 @@ Console.log("---") Console.log("Intl.ListFormat") let _formatter = Intl.ListFormat.make() -let _formatter = Intl.ListFormat.makeWithLocale("en-US") -let _formatter = Intl.ListFormat.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.ListFormat.makeWithLocaleAndOptions( - "en-US", - {style: #long, \"type": #conjunction}, -) -let _formatter = Intl.ListFormat.makeWithLocalesAndOptions( - ["en-US", "en-GB"], - {style: #long, \"type": #conjunction}, +let _formatter = Intl.ListFormat.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.ListFormat.make( + ~locales=["en-US", "en-GB"], + ~options={style: #long, \"type": #conjunction}, ) Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.ListFormat.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore +Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore -let formatter = Intl.ListFormat.makeWithOptions({style: #long, \"type": #conjunction}) +let formatter = Intl.ListFormat.make(~options={style: #long, \"type": #conjunction}) formatter->Intl.ListFormat.resolvedOptions->Console.log formatter->Intl.ListFormat.format(["one", "two", "three"])->Console.log diff --git a/test/intl/Intl__LocaleTest.mjs b/test/intl/Intl__LocaleTest.mjs index a8349a84..f58897c3 100644 --- a/test/intl/Intl__LocaleTest.mjs +++ b/test/intl/Intl__LocaleTest.mjs @@ -5,7 +5,7 @@ console.log("---"); console.log("Intl.Locale"); -var _locale = new Intl.Locale("en-US"); +var _locale = new Intl.Locale("en-US", undefined); var locale = new Intl.Locale("en-US", { calendar: "hebrew", diff --git a/test/intl/Intl__LocaleTest.res b/test/intl/Intl__LocaleTest.res index 543d8004..b91e5001 100644 --- a/test/intl/Intl__LocaleTest.res +++ b/test/intl/Intl__LocaleTest.res @@ -4,9 +4,9 @@ Console.log("---") Console.log("Intl.Locale") let _locale = Intl.Locale.make("en-US") -let locale = Intl.Locale.makeWithOptions( +let locale = Intl.Locale.make( "en-US", - { + ~options={ calendar: #hebrew, collation: #compat, hourCycle: #h24, diff --git a/test/intl/Intl__NumberFormatTest.mjs b/test/intl/Intl__NumberFormatTest.mjs index d19804e9..9f8e02d9 100644 --- a/test/intl/Intl__NumberFormatTest.mjs +++ b/test/intl/Intl__NumberFormatTest.mjs @@ -7,7 +7,7 @@ console.log("---"); console.log("Intl.NumberFormat"); -var currencyFormatter = new Intl.NumberFormat("fr-FR", { +var currencyFormatter = new Intl.NumberFormat(["fr-FR"], { currency: "EUR", style: "currency" }); @@ -15,7 +15,7 @@ var currencyFormatter = new Intl.NumberFormat("fr-FR", { console.log(Intl.NumberFormat.supportedLocalesOf([ "fr-FR", "en-US" - ])); + ], undefined)); console.log(currencyFormatter.format(123.23)); diff --git a/test/intl/Intl__NumberFormatTest.res b/test/intl/Intl__NumberFormatTest.res index 51829077..b6c1595f 100644 --- a/test/intl/Intl__NumberFormatTest.res +++ b/test/intl/Intl__NumberFormatTest.res @@ -3,34 +3,42 @@ open RescriptCore Console.log("---") Console.log("Intl.NumberFormat") -let currencyFormatter = Intl.NumberFormat.makeWithLocaleAndOptions( - "fr-FR", - {currency: "EUR", style: #currency}, +let currencyFormatter = Intl.NumberFormat.make( + ~locales=["fr-FR"], + ~options={currency: "EUR", style: #currency}, ) Console.log(Intl.NumberFormat.supportedLocalesOf(["fr-FR", "en-US"])) Console.log(currencyFormatter->Intl.NumberFormat.format(123.23)) -let roundingFormatter = Intl.NumberFormat.makeWithOptions({ - roundingIncrement: #500, - minimumFractionDigits: #2, - maximumFractionDigits: #2, -}) +let roundingFormatter = Intl.NumberFormat.make( + ~options={ + roundingIncrement: #500, + minimumFractionDigits: #2, + maximumFractionDigits: #2, + }, +) -let groupingFormatter1 = Intl.NumberFormat.makeWithOptions({ - useGrouping: Intl.NumberFormat.Grouping.fromBool(true), -}) -let groupingFormatter2 = Intl.NumberFormat.makeWithOptions({ - useGrouping: Intl.NumberFormat.Grouping.fromString(#auto), -}) +let groupingFormatter1 = Intl.NumberFormat.make( + ~options={ + useGrouping: Intl.NumberFormat.Grouping.fromBool(true), + }, +) +let groupingFormatter2 = Intl.NumberFormat.make( + ~options={ + useGrouping: Intl.NumberFormat.Grouping.fromString(#auto), + }, +) -let sigFormatter = Intl.NumberFormat.makeWithOptions({ - minimumIntegerDigits: #1, - minimumFractionDigits: #1, - maximumFractionDigits: #1, - minimumSignificantDigits: #1, - maximumSignificantDigits: #1, -}) +let sigFormatter = Intl.NumberFormat.make( + ~options={ + minimumIntegerDigits: #1, + minimumFractionDigits: #1, + maximumFractionDigits: #1, + minimumSignificantDigits: #1, + maximumSignificantDigits: #1, + }, +) let options = sigFormatter->Intl.NumberFormat.resolvedOptions Console.log(options) diff --git a/test/intl/Intl__PluralRulesTest.mjs b/test/intl/Intl__PluralRulesTest.mjs index b4fe8030..786eb15a 100644 --- a/test/intl/Intl__PluralRulesTest.mjs +++ b/test/intl/Intl__PluralRulesTest.mjs @@ -5,22 +5,14 @@ console.log("---"); console.log("Intl.PluralRules"); -new Intl.PluralRules(); - -new Intl.PluralRules("en-US"); +new Intl.PluralRules(undefined, undefined); new Intl.PluralRules([ "en-US", "en-GB" - ]); - -new Intl.PluralRules(undefined, { - type: "ordinal", - minimumSignificantDigits: 3, - maximumSignificantDigits: 5 - }); + ], undefined); -var _formatter = new Intl.PluralRules("en-US", { +var _formatter = new Intl.PluralRules(undefined, { type: "ordinal", minimumSignificantDigits: 3, maximumSignificantDigits: 5 diff --git a/test/intl/Intl__PluralRulesTest.res b/test/intl/Intl__PluralRulesTest.res index 4f56404c..30710414 100644 --- a/test/intl/Intl__PluralRulesTest.res +++ b/test/intl/Intl__PluralRulesTest.res @@ -4,24 +4,17 @@ Console.log("---") Console.log("Intl.PluralRules") let _formatter = Intl.PluralRules.make() -let _formatter = Intl.PluralRules.makeWithLocale("en-US") -let _formatter = Intl.PluralRules.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.PluralRules.makeWithOptions({ - \"type": #ordinal, - maximumSignificantDigits: #5, - minimumSignificantDigits: #3, -}) -let _formatter = Intl.PluralRules.makeWithLocaleAndOptions( - "en-US", - { +let _formatter = Intl.PluralRules.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.PluralRules.make( + ~options={ \"type": #ordinal, maximumSignificantDigits: #5, minimumSignificantDigits: #3, }, ) -let formatter = Intl.PluralRules.makeWithLocalesAndOptions( - ["en-US"], - { +let formatter = Intl.PluralRules.make( + ~locales=["en-US"], + ~options={ \"type": #ordinal, maximumSignificantDigits: #5, minimumSignificantDigits: #3, diff --git a/test/intl/Intl__RelativeTimeFormatTest.mjs b/test/intl/Intl__RelativeTimeFormatTest.mjs index 062d89be..2afbbac3 100644 --- a/test/intl/Intl__RelativeTimeFormatTest.mjs +++ b/test/intl/Intl__RelativeTimeFormatTest.mjs @@ -8,7 +8,7 @@ console.log("Intl.RelativeTimeFormat"); Intl.RelativeTimeFormat.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.RelativeTimeFormat.supportedLocalesOf([ "en-US", @@ -17,21 +17,14 @@ Intl.RelativeTimeFormat.supportedLocalesOf([ localeMatcher: "lookup" }); -new Intl.RelativeTimeFormat(); - -new Intl.RelativeTimeFormat("en-US"); +new Intl.RelativeTimeFormat(undefined, undefined); new Intl.RelativeTimeFormat([ "en-US", "en-GB" - ]); - -new Intl.RelativeTimeFormat(undefined, { - numeric: "always", - style: "narrow" - }); + ], undefined); -var _formatter = new Intl.RelativeTimeFormat("en-US", { +var _formatter = new Intl.RelativeTimeFormat(undefined, { numeric: "always", style: "narrow" }); diff --git a/test/intl/Intl__RelativeTimeFormatTest.res b/test/intl/Intl__RelativeTimeFormatTest.res index e8833d7c..6f53ad7e 100644 --- a/test/intl/Intl__RelativeTimeFormatTest.res +++ b/test/intl/Intl__RelativeTimeFormatTest.res @@ -4,28 +4,22 @@ Console.log("---") Console.log("Intl.RelativeTimeFormat") Intl.RelativeTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.RelativeTimeFormat.supportedLocalesOfWithOptions( +Intl.RelativeTimeFormat.supportedLocalesOf( ["en-US", "en-GB"], - {localeMatcher: #lookup}, + ~options={localeMatcher: #lookup}, )->ignore let _formatter = Intl.RelativeTimeFormat.make() -let _formatter = Intl.RelativeTimeFormat.makeWithLocale("en-US") -let _formatter = Intl.RelativeTimeFormat.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.RelativeTimeFormat.makeWithOptions({ - numeric: #always, - style: #narrow, -}) -let _formatter = Intl.RelativeTimeFormat.makeWithLocaleAndOptions( - "en-US", - { +let _formatter = Intl.RelativeTimeFormat.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.RelativeTimeFormat.make( + ~options={ numeric: #always, style: #narrow, }, ) -let formatter = Intl.RelativeTimeFormat.makeWithLocalesAndOptions( - ["en-US"], - { +let formatter = Intl.RelativeTimeFormat.make( + ~locales=["en-US"], + ~options={ numeric: #always, style: #narrow, }, diff --git a/test/intl/Intl__SegmenterTest.mjs b/test/intl/Intl__SegmenterTest.mjs index 757c7c4d..c1d6ecf0 100644 --- a/test/intl/Intl__SegmenterTest.mjs +++ b/test/intl/Intl__SegmenterTest.mjs @@ -8,7 +8,7 @@ console.log("Intl.Segmenter"); Intl.Segmenter.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.Segmenter.supportedLocalesOf([ "en-US", @@ -17,20 +17,14 @@ Intl.Segmenter.supportedLocalesOf([ localeMatcher: "lookup" }); -new Intl.Segmenter(); - -new Intl.Segmenter("en-US"); +new Intl.Segmenter(undefined, undefined); new Intl.Segmenter([ "en-US", "en-GB" - ]); - -new Intl.Segmenter(undefined, { - granularity: "word" - }); + ], undefined); -var _formatter = new Intl.Segmenter("en-US", { +var _formatter = new Intl.Segmenter(undefined, { granularity: "word" }); diff --git a/test/intl/Intl__SegmenterTest.res b/test/intl/Intl__SegmenterTest.res index aaca4153..ed322939 100644 --- a/test/intl/Intl__SegmenterTest.res +++ b/test/intl/Intl__SegmenterTest.res @@ -4,23 +4,18 @@ Console.log("---") Console.log("Intl.Segmenter") Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.Segmenter.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore +Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore let _formatter = Intl.Segmenter.make() -let _formatter = Intl.Segmenter.makeWithLocale("en-US") -let _formatter = Intl.Segmenter.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.Segmenter.makeWithOptions({ - granularity: #word, -}) -let _formatter = Intl.Segmenter.makeWithLocaleAndOptions( - "en-US", - { +let _formatter = Intl.Segmenter.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.Segmenter.make( + ~options={ granularity: #word, }, ) -let formatter = Intl.Segmenter.makeWithLocalesAndOptions( - ["en-US"], - { +let formatter = Intl.Segmenter.make( + ~locales=["en-US"], + ~options={ granularity: #word, }, )