githrun

A CLI tool to run Python scrip...
Log | Files | Refs | README | LICENSE

lib.es2022.intl.d.ts (7692B)


      1 /*! *****************************************************************************
      2 Copyright (c) Microsoft Corporation. All rights reserved.
      3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
      4 this file except in compliance with the License. You may obtain a copy of the
      5 License at http://www.apache.org/licenses/LICENSE-2.0
      6 
      7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
      8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
      9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
     10 MERCHANTABLITY OR NON-INFRINGEMENT.
     11 
     12 See the Apache Version 2.0 License for specific language governing permissions
     13 and limitations under the License.
     14 ***************************************************************************** */
     15 
     16 
     17 /// <reference no-default-lib="true"/>
     18 
     19 declare namespace Intl {
     20     /**
     21      * An object with some or all properties of the `Intl.Segmenter` constructor `options` parameter.
     22      *
     23      * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters)
     24      */
     25     interface SegmenterOptions {
     26         /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
     27         localeMatcher?: "best fit" | "lookup" | undefined;
     28         /** The type of input to be split */
     29         granularity?: "grapheme" | "word" | "sentence" | undefined;
     30     }
     31 
     32     /**
     33      * The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string.
     34      *
     35      * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
     36      */
     37     interface Segmenter {
     38         /**
     39          * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity.
     40          *
     41          * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment)
     42          *
     43          * @param input - The text to be segmented as a `string`.
     44          *
     45          * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity.
     46          */
     47         segment(input: string): Segments;
     48         /**
     49          * The `resolvedOptions()` method of `Intl.Segmenter` instances returns a new object with properties reflecting the options computed during initialization of this `Segmenter` object.
     50          *
     51          * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions)
     52          */
     53         resolvedOptions(): ResolvedSegmenterOptions;
     54     }
     55 
     56     interface ResolvedSegmenterOptions {
     57         locale: string;
     58         granularity: "grapheme" | "word" | "sentence";
     59     }
     60 
     61     interface SegmentIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
     62         [Symbol.iterator](): SegmentIterator<T>;
     63     }
     64 
     65     /**
     66      * A `Segments` object is an iterable collection of the segments of a text string. It is returned by a call to the `segment()` method of an `Intl.Segmenter` object.
     67      *
     68      * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments)
     69      */
     70     interface Segments {
     71         /**
     72          * Returns an object describing the segment in the original string that includes the code unit at a specified index.
     73          *
     74          * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing)
     75          *
     76          * @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`.
     77          */
     78         containing(codeUnitIndex?: number): SegmentData | undefined;
     79 
     80         /** Returns an iterator to iterate over the segments. */
     81         [Symbol.iterator](): SegmentIterator<SegmentData>;
     82     }
     83 
     84     interface SegmentData {
     85         /** A string containing the segment extracted from the original input string. */
     86         segment: string;
     87         /** The code unit index in the original input string at which the segment begins. */
     88         index: number;
     89         /** The complete input string that was segmented. */
     90         input: string;
     91         /**
     92          * A boolean value only if granularity is "word"; otherwise, undefined.
     93          * If granularity is "word", then isWordLike is true when the segment is word-like (i.e., consists of letters/numbers/ideographs/etc.); otherwise, false.
     94          */
     95         isWordLike?: boolean;
     96     }
     97 
     98     /**
     99      * The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string.
    100      *
    101      * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)
    102      */
    103     const Segmenter: {
    104         prototype: Segmenter;
    105 
    106         /**
    107          * Creates a new `Intl.Segmenter` object.
    108          *
    109          * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
    110          *  For the general form and interpretation of the `locales` argument,
    111          *  see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
    112          *
    113          * @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters)
    114          *  with some or all options of `SegmenterOptions`.
    115          *
    116          * @returns [Intl.Segmenter](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments) object.
    117          *
    118          * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter).
    119          */
    120         new (locales?: LocalesArgument, options?: SegmenterOptions): Segmenter;
    121 
    122         /**
    123          * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
    124          *
    125          * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
    126          *  For the general form and interpretation of the `locales` argument,
    127          *  see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
    128          *
    129          * @param options An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf#parameters).
    130          *  with some or all possible options.
    131          *
    132          * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf)
    133          */
    134         supportedLocalesOf(locales: LocalesArgument, options?: Pick<SegmenterOptions, "localeMatcher">): UnicodeBCP47LocaleIdentifier[];
    135     };
    136 
    137     /**
    138      * Returns a sorted array of the supported collation, calendar, currency, numbering system, timezones, and units by the implementation.
    139      * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
    140      *
    141      * @param key A string indicating the category of values to return.
    142      * @returns A sorted array of the supported values.
    143      */
    144     function supportedValuesOf(key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"): string[];
    145 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror