diff --git a/dist/bundled.d.ts b/dist/bundled.d.ts index 2162901..e8505d5 100644 --- a/dist/bundled.d.ts +++ b/dist/bundled.d.ts @@ -1,16 +1,9 @@ +import { IntlSegmenterOptions, Segment } from '.'; + export declare const createIntlSegmenterPolyfill: () => Promise<{ - new (locale: string, options: { - granularity: "word" | "grapheme"; - }): { - locale: string; - options: { - granularity: "word" | "grapheme"; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; - }; + new (locale: string, options: IntlSegmenterOptions): { + locale: string; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; + }; }>; diff --git a/dist/bundled_cja.d.ts b/dist/bundled_cja.d.ts index 2162901..e8505d5 100644 --- a/dist/bundled_cja.d.ts +++ b/dist/bundled_cja.d.ts @@ -1,16 +1,9 @@ +import { IntlSegmenterOptions, Segment } from '.'; + export declare const createIntlSegmenterPolyfill: () => Promise<{ - new (locale: string, options: { - granularity: "word" | "grapheme"; - }): { - locale: string; - options: { - granularity: "word" | "grapheme"; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; - }; + new (locale: string, options: IntlSegmenterOptions): { + locale: string; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; + }; }>; diff --git a/dist/index.d.ts b/dist/index.d.ts index e96457e..75780b2 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,35 +1,29 @@ import 'fast-text-encoding'; + +export type IntlSegmenterOptions = { + granularity: 'word' | 'grapheme' | 'sentence' +} + +export type Segment = { + segment: string; + index: number; + isWordLike: boolean; + breakType: "number" | "none" | "word" | "kana" | "ideo"; +} + export declare const createIntlSegmenterPolyfillFromFactory: (wasmFactory: (imports: Object) => { instance: WebAssembly.Instance; }) => Promise<{ - new (locale: string, options: { - granularity: 'word' | 'grapheme'; - }): { + new (locale: string, options: IntlSegmenterOptions): { locale: string; - options: { - granularity: 'word' | 'grapheme'; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; }; }>; export declare const createIntlSegmenterPolyfill: (wasm: ArrayBufferLike | PromiseLike) => Promise<{ - new (locale: string, options: { - granularity: 'word' | 'grapheme'; - }): { + new (locale: string, options: IntlSegmenterOptions): { locale: string; - options: { - granularity: 'word' | 'grapheme'; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; }; }>; diff --git a/package.json b/package.json index dba263d..66f1f69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intl-segmenter-polyfill", - "version": "0.4.4", + "version": "0.4.5", "description": "This repo builds .wasm module using icu4c for breaking text into words, so that we can polyfill [Intl Segmenter Proposal](https://github.com/tc39/proposal-intl-segmenter) with full compatibility, even on browsers that do not expose v8BreakIterator api.", "main": "dist/index.js", "files": [ diff --git a/src/bundled.d.ts b/src/bundled.d.ts index 2162901..e8505d5 100644 --- a/src/bundled.d.ts +++ b/src/bundled.d.ts @@ -1,16 +1,9 @@ +import { IntlSegmenterOptions, Segment } from '.'; + export declare const createIntlSegmenterPolyfill: () => Promise<{ - new (locale: string, options: { - granularity: "word" | "grapheme"; - }): { - locale: string; - options: { - granularity: "word" | "grapheme"; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; - }; + new (locale: string, options: IntlSegmenterOptions): { + locale: string; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; + }; }>; diff --git a/src/index.d.ts b/src/index.d.ts index e96457e..75780b2 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,35 +1,29 @@ import 'fast-text-encoding'; + +export type IntlSegmenterOptions = { + granularity: 'word' | 'grapheme' | 'sentence' +} + +export type Segment = { + segment: string; + index: number; + isWordLike: boolean; + breakType: "number" | "none" | "word" | "kana" | "ideo"; +} + export declare const createIntlSegmenterPolyfillFromFactory: (wasmFactory: (imports: Object) => { instance: WebAssembly.Instance; }) => Promise<{ - new (locale: string, options: { - granularity: 'word' | 'grapheme'; - }): { + new (locale: string, options: IntlSegmenterOptions): { locale: string; - options: { - granularity: 'word' | 'grapheme'; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; }; }>; export declare const createIntlSegmenterPolyfill: (wasm: ArrayBufferLike | PromiseLike) => Promise<{ - new (locale: string, options: { - granularity: 'word' | 'grapheme'; - }): { + new (locale: string, options: IntlSegmenterOptions): { locale: string; - options: { - granularity: 'word' | 'grapheme'; - }; - segment(input: string): { - segment: string; - index: number; - isWordLike: boolean; - breakType: "number" | "none" | "word" | "kana" | "ideo"; - }[]; + options: IntlSegmenterOptions; + segment(input: string): Segment[]; }; }>;