Skip to content

Commit 0cd6959

Browse files
feat: Intl.Segmenter
1 parent 089cab1 commit 0cd6959

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

src/intl/Core__Intl__Segmenter.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

src/intl/Core__Intl__Segmenter.res

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/***
2+
Not supported in Firefox
3+
*/
4+
type t
5+
6+
type granularity = [#grapheme | #word | #sentence]
7+
8+
type options = {
9+
localeMatcher?: Core__Intl__Common.localeMatcher,
10+
granularity?: granularity,
11+
}
12+
13+
type pluralCategories = [
14+
| #zero
15+
| #one
16+
| #two
17+
| #few
18+
| #many
19+
| #other
20+
]
21+
22+
type resolvedOptions = {locale: string, granularity: granularity}
23+
24+
type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher}
25+
26+
@new external make: unit => t = "Intl.Segmenter"
27+
@new external makeWithLocale: string => t = "Intl.Segmenter"
28+
@new external makeWithLocales: array<string> => t = "Intl.Segmenter"
29+
@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Segmenter"
30+
@new external makeWithLocalesAndOptions: (array<string>, options) => t = "Intl.Segmenter"
31+
@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Segmenter"
32+
33+
@val external supportedLocalesOf: array<string> => t = "Intl.Segmenter.supportedLocalesOf"
34+
@val
35+
external supportedLocalesOfWithOptions: (array<string>, supportedLocalesOptions) => t =
36+
"Intl.Segmenter.supportedLocalesOf"
37+
38+
@send external resolvedOptions: t => resolvedOptions = "resolvedOptions"
39+
40+
@send external segment: (t, string) => Core__Intl__Segments.t = "segment"

src/intl/Core__Intl__Segments.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

src/intl/Core__Intl__Segments.res

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/***
2+
A Segments instance is an object that represents the segments of a specific string, subject to the locale and options of its constructing Intl.Segmenter instance.
3+
https://tc39.es/ecma402/#sec-segments-objects
4+
*/
5+
type t
6+
7+
type segmentData = {
8+
segment: string,
9+
index: int,
10+
isWordLike: option<bool>,
11+
input: string,
12+
}
13+
14+
@send
15+
external containing: unit => segmentData = "containing"
16+
17+
@send
18+
external containingWithIndex: int => segmentData = "containing"

0 commit comments

Comments
 (0)