githrun

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

root / vscode-githrun / node_modules / typescript / lib / lib.es2015.iterable.d.ts

lib.es2015.iterable.d.ts (18200B)


      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 /// <reference lib="es2015.symbol" />
     20 
     21 interface SymbolConstructor {
     22     /**
     23      * A method that returns the default iterator for an object. Called by the semantics of the
     24      * for-of statement.
     25      */
     26     readonly iterator: unique symbol;
     27 }
     28 
     29 interface IteratorYieldResult<TYield> {
     30     done?: false;
     31     value: TYield;
     32 }
     33 
     34 interface IteratorReturnResult<TReturn> {
     35     done: true;
     36     value: TReturn;
     37 }
     38 
     39 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
     40 
     41 interface Iterator<T, TReturn = any, TNext = any> {
     42     // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
     43     next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
     44     return?(value?: TReturn): IteratorResult<T, TReturn>;
     45     throw?(e?: any): IteratorResult<T, TReturn>;
     46 }
     47 
     48 interface Iterable<T, TReturn = any, TNext = any> {
     49     [Symbol.iterator](): Iterator<T, TReturn, TNext>;
     50 }
     51 
     52 /**
     53  * Describes a user-defined {@link Iterator} that is also iterable.
     54  */
     55 interface IterableIterator<T, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
     56     [Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
     57 }
     58 
     59 /**
     60  * Describes an {@link Iterator} produced by the runtime that inherits from the intrinsic `Iterator.prototype`.
     61  */
     62 interface IteratorObject<T, TReturn = unknown, TNext = unknown> extends Iterator<T, TReturn, TNext> {
     63     [Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
     64 }
     65 
     66 /**
     67  * Defines the `TReturn` type used for built-in iterators produced by `Array`, `Map`, `Set`, and others.
     68  * This is `undefined` when `strictBuiltInIteratorReturn` is `true`; otherwise, this is `any`.
     69  */
     70 type BuiltinIteratorReturn = intrinsic;
     71 
     72 interface ArrayIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
     73     [Symbol.iterator](): ArrayIterator<T>;
     74 }
     75 
     76 interface Array<T> {
     77     /** Iterator */
     78     [Symbol.iterator](): ArrayIterator<T>;
     79 
     80     /**
     81      * Returns an iterable of key, value pairs for every entry in the array
     82      */
     83     entries(): ArrayIterator<[number, T]>;
     84 
     85     /**
     86      * Returns an iterable of keys in the array
     87      */
     88     keys(): ArrayIterator<number>;
     89 
     90     /**
     91      * Returns an iterable of values in the array
     92      */
     93     values(): ArrayIterator<T>;
     94 }
     95 
     96 interface ArrayConstructor {
     97     /**
     98      * Creates an array from an iterable object.
     99      * @param iterable An iterable object to convert to an array.
    100      */
    101     from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
    102 
    103     /**
    104      * Creates an array from an iterable object.
    105      * @param iterable An iterable object to convert to an array.
    106      * @param mapfn A mapping function to call on every element of the array.
    107      * @param thisArg Value of 'this' used to invoke the mapfn.
    108      */
    109     from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
    110 }
    111 
    112 interface ReadonlyArray<T> {
    113     /** Iterator of values in the array. */
    114     [Symbol.iterator](): ArrayIterator<T>;
    115 
    116     /**
    117      * Returns an iterable of key, value pairs for every entry in the array
    118      */
    119     entries(): ArrayIterator<[number, T]>;
    120 
    121     /**
    122      * Returns an iterable of keys in the array
    123      */
    124     keys(): ArrayIterator<number>;
    125 
    126     /**
    127      * Returns an iterable of values in the array
    128      */
    129     values(): ArrayIterator<T>;
    130 }
    131 
    132 interface IArguments {
    133     /** Iterator */
    134     [Symbol.iterator](): ArrayIterator<any>;
    135 }
    136 
    137 interface MapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
    138     [Symbol.iterator](): MapIterator<T>;
    139 }
    140 
    141 interface Map<K, V> {
    142     /** Returns an iterable of entries in the map. */
    143     [Symbol.iterator](): MapIterator<[K, V]>;
    144 
    145     /**
    146      * Returns an iterable of key, value pairs for every entry in the map.
    147      */
    148     entries(): MapIterator<[K, V]>;
    149 
    150     /**
    151      * Returns an iterable of keys in the map
    152      */
    153     keys(): MapIterator<K>;
    154 
    155     /**
    156      * Returns an iterable of values in the map
    157      */
    158     values(): MapIterator<V>;
    159 }
    160 
    161 interface ReadonlyMap<K, V> {
    162     /** Returns an iterable of entries in the map. */
    163     [Symbol.iterator](): MapIterator<[K, V]>;
    164 
    165     /**
    166      * Returns an iterable of key, value pairs for every entry in the map.
    167      */
    168     entries(): MapIterator<[K, V]>;
    169 
    170     /**
    171      * Returns an iterable of keys in the map
    172      */
    173     keys(): MapIterator<K>;
    174 
    175     /**
    176      * Returns an iterable of values in the map
    177      */
    178     values(): MapIterator<V>;
    179 }
    180 
    181 interface MapConstructor {
    182     new (): Map<any, any>;
    183     new <K, V>(iterable?: Iterable<readonly [K, V]> | null): Map<K, V>;
    184 }
    185 
    186 interface WeakMap<K extends WeakKey, V> {}
    187 
    188 interface WeakMapConstructor {
    189     new <K extends WeakKey, V>(iterable: Iterable<readonly [K, V]>): WeakMap<K, V>;
    190 }
    191 
    192 interface SetIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
    193     [Symbol.iterator](): SetIterator<T>;
    194 }
    195 
    196 interface Set<T> {
    197     /** Iterates over values in the set. */
    198     [Symbol.iterator](): SetIterator<T>;
    199 
    200     /**
    201      * Returns an iterable of [v,v] pairs for every value `v` in the set.
    202      */
    203     entries(): SetIterator<[T, T]>;
    204 
    205     /**
    206      * Despite its name, returns an iterable of the values in the set.
    207      */
    208     keys(): SetIterator<T>;
    209 
    210     /**
    211      * Returns an iterable of values in the set.
    212      */
    213     values(): SetIterator<T>;
    214 }
    215 
    216 interface ReadonlySet<T> {
    217     /** Iterates over values in the set. */
    218     [Symbol.iterator](): SetIterator<T>;
    219 
    220     /**
    221      * Returns an iterable of [v,v] pairs for every value `v` in the set.
    222      */
    223     entries(): SetIterator<[T, T]>;
    224 
    225     /**
    226      * Despite its name, returns an iterable of the values in the set.
    227      */
    228     keys(): SetIterator<T>;
    229 
    230     /**
    231      * Returns an iterable of values in the set.
    232      */
    233     values(): SetIterator<T>;
    234 }
    235 
    236 interface SetConstructor {
    237     new <T>(iterable?: Iterable<T> | null): Set<T>;
    238 }
    239 
    240 interface WeakSet<T extends WeakKey> {}
    241 
    242 interface WeakSetConstructor {
    243     new <T extends WeakKey = WeakKey>(iterable: Iterable<T>): WeakSet<T>;
    244 }
    245 
    246 interface Promise<T> {}
    247 
    248 interface PromiseConstructor {
    249     /**
    250      * Creates a Promise that is resolved with an array of results when all of the provided Promises
    251      * resolve, or rejected when any Promise is rejected.
    252      * @param values An iterable of Promises.
    253      * @returns A new Promise.
    254      */
    255     all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
    256 
    257     /**
    258      * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
    259      * or rejected.
    260      * @param values An iterable of Promises.
    261      * @returns A new Promise.
    262      */
    263     race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
    264 }
    265 
    266 interface StringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
    267     [Symbol.iterator](): StringIterator<T>;
    268 }
    269 
    270 interface String {
    271     /** Iterator */
    272     [Symbol.iterator](): StringIterator<string>;
    273 }
    274 
    275 interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
    276     [Symbol.iterator](): ArrayIterator<number>;
    277 
    278     /**
    279      * Returns an array of key, value pairs for every entry in the array
    280      */
    281     entries(): ArrayIterator<[number, number]>;
    282 
    283     /**
    284      * Returns an list of keys in the array
    285      */
    286     keys(): ArrayIterator<number>;
    287 
    288     /**
    289      * Returns an list of values in the array
    290      */
    291     values(): ArrayIterator<number>;
    292 }
    293 
    294 interface Int8ArrayConstructor {
    295     new (elements: Iterable<number>): Int8Array<ArrayBuffer>;
    296 
    297     /**
    298      * Creates an array from an array-like or iterable object.
    299      * @param elements An iterable object to convert to an array.
    300      */
    301     from(elements: Iterable<number>): Int8Array<ArrayBuffer>;
    302 
    303     /**
    304      * Creates an array from an array-like or iterable object.
    305      * @param elements An iterable object to convert to an array.
    306      * @param mapfn A mapping function to call on every element of the array.
    307      * @param thisArg Value of 'this' used to invoke the mapfn.
    308      */
    309     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int8Array<ArrayBuffer>;
    310 }
    311 
    312 interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
    313     [Symbol.iterator](): ArrayIterator<number>;
    314 
    315     /**
    316      * Returns an array of key, value pairs for every entry in the array
    317      */
    318     entries(): ArrayIterator<[number, number]>;
    319 
    320     /**
    321      * Returns an list of keys in the array
    322      */
    323     keys(): ArrayIterator<number>;
    324 
    325     /**
    326      * Returns an list of values in the array
    327      */
    328     values(): ArrayIterator<number>;
    329 }
    330 
    331 interface Uint8ArrayConstructor {
    332     new (elements: Iterable<number>): Uint8Array<ArrayBuffer>;
    333 
    334     /**
    335      * Creates an array from an array-like or iterable object.
    336      * @param elements An iterable object to convert to an array.
    337      */
    338     from(elements: Iterable<number>): Uint8Array<ArrayBuffer>;
    339 
    340     /**
    341      * Creates an array from an array-like or iterable object.
    342      * @param elements An iterable object to convert to an array.
    343      * @param mapfn A mapping function to call on every element of the array.
    344      * @param thisArg Value of 'this' used to invoke the mapfn.
    345      */
    346     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8Array<ArrayBuffer>;
    347 }
    348 
    349 interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
    350     [Symbol.iterator](): ArrayIterator<number>;
    351 
    352     /**
    353      * Returns an array of key, value pairs for every entry in the array
    354      */
    355     entries(): ArrayIterator<[number, number]>;
    356 
    357     /**
    358      * Returns an list of keys in the array
    359      */
    360     keys(): ArrayIterator<number>;
    361 
    362     /**
    363      * Returns an list of values in the array
    364      */
    365     values(): ArrayIterator<number>;
    366 }
    367 
    368 interface Uint8ClampedArrayConstructor {
    369     new (elements: Iterable<number>): Uint8ClampedArray<ArrayBuffer>;
    370 
    371     /**
    372      * Creates an array from an array-like or iterable object.
    373      * @param elements An iterable object to convert to an array.
    374      */
    375     from(elements: Iterable<number>): Uint8ClampedArray<ArrayBuffer>;
    376 
    377     /**
    378      * Creates an array from an array-like or iterable object.
    379      * @param elements An iterable object to convert to an array.
    380      * @param mapfn A mapping function to call on every element of the array.
    381      * @param thisArg Value of 'this' used to invoke the mapfn.
    382      */
    383     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray<ArrayBuffer>;
    384 }
    385 
    386 interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
    387     [Symbol.iterator](): ArrayIterator<number>;
    388     /**
    389      * Returns an array of key, value pairs for every entry in the array
    390      */
    391     entries(): ArrayIterator<[number, number]>;
    392 
    393     /**
    394      * Returns an list of keys in the array
    395      */
    396     keys(): ArrayIterator<number>;
    397 
    398     /**
    399      * Returns an list of values in the array
    400      */
    401     values(): ArrayIterator<number>;
    402 }
    403 
    404 interface Int16ArrayConstructor {
    405     new (elements: Iterable<number>): Int16Array<ArrayBuffer>;
    406 
    407     /**
    408      * Creates an array from an array-like or iterable object.
    409      * @param elements An iterable object to convert to an array.
    410      */
    411     from(elements: Iterable<number>): Int16Array<ArrayBuffer>;
    412 
    413     /**
    414      * Creates an array from an array-like or iterable object.
    415      * @param elements An iterable object to convert to an array.
    416      * @param mapfn A mapping function to call on every element of the array.
    417      * @param thisArg Value of 'this' used to invoke the mapfn.
    418      */
    419     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int16Array<ArrayBuffer>;
    420 }
    421 
    422 interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
    423     [Symbol.iterator](): ArrayIterator<number>;
    424 
    425     /**
    426      * Returns an array of key, value pairs for every entry in the array
    427      */
    428     entries(): ArrayIterator<[number, number]>;
    429 
    430     /**
    431      * Returns an list of keys in the array
    432      */
    433     keys(): ArrayIterator<number>;
    434 
    435     /**
    436      * Returns an list of values in the array
    437      */
    438     values(): ArrayIterator<number>;
    439 }
    440 
    441 interface Uint16ArrayConstructor {
    442     new (elements: Iterable<number>): Uint16Array<ArrayBuffer>;
    443 
    444     /**
    445      * Creates an array from an array-like or iterable object.
    446      * @param elements An iterable object to convert to an array.
    447      */
    448     from(elements: Iterable<number>): Uint16Array<ArrayBuffer>;
    449 
    450     /**
    451      * Creates an array from an array-like or iterable object.
    452      * @param elements An iterable object to convert to an array.
    453      * @param mapfn A mapping function to call on every element of the array.
    454      * @param thisArg Value of 'this' used to invoke the mapfn.
    455      */
    456     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint16Array<ArrayBuffer>;
    457 }
    458 
    459 interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
    460     [Symbol.iterator](): ArrayIterator<number>;
    461 
    462     /**
    463      * Returns an array of key, value pairs for every entry in the array
    464      */
    465     entries(): ArrayIterator<[number, number]>;
    466 
    467     /**
    468      * Returns an list of keys in the array
    469      */
    470     keys(): ArrayIterator<number>;
    471 
    472     /**
    473      * Returns an list of values in the array
    474      */
    475     values(): ArrayIterator<number>;
    476 }
    477 
    478 interface Int32ArrayConstructor {
    479     new (elements: Iterable<number>): Int32Array<ArrayBuffer>;
    480 
    481     /**
    482      * Creates an array from an array-like or iterable object.
    483      * @param elements An iterable object to convert to an array.
    484      */
    485     from(elements: Iterable<number>): Int32Array<ArrayBuffer>;
    486 
    487     /**
    488      * Creates an array from an array-like or iterable object.
    489      * @param elements An iterable object to convert to an array.
    490      * @param mapfn A mapping function to call on every element of the array.
    491      * @param thisArg Value of 'this' used to invoke the mapfn.
    492      */
    493     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Int32Array<ArrayBuffer>;
    494 }
    495 
    496 interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
    497     [Symbol.iterator](): ArrayIterator<number>;
    498 
    499     /**
    500      * Returns an array of key, value pairs for every entry in the array
    501      */
    502     entries(): ArrayIterator<[number, number]>;
    503 
    504     /**
    505      * Returns an list of keys in the array
    506      */
    507     keys(): ArrayIterator<number>;
    508 
    509     /**
    510      * Returns an list of values in the array
    511      */
    512     values(): ArrayIterator<number>;
    513 }
    514 
    515 interface Uint32ArrayConstructor {
    516     new (elements: Iterable<number>): Uint32Array<ArrayBuffer>;
    517 
    518     /**
    519      * Creates an array from an array-like or iterable object.
    520      * @param elements An iterable object to convert to an array.
    521      */
    522     from(elements: Iterable<number>): Uint32Array<ArrayBuffer>;
    523 
    524     /**
    525      * Creates an array from an array-like or iterable object.
    526      * @param elements An iterable object to convert to an array.
    527      * @param mapfn A mapping function to call on every element of the array.
    528      * @param thisArg Value of 'this' used to invoke the mapfn.
    529      */
    530     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Uint32Array<ArrayBuffer>;
    531 }
    532 
    533 interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
    534     [Symbol.iterator](): ArrayIterator<number>;
    535 
    536     /**
    537      * Returns an array of key, value pairs for every entry in the array
    538      */
    539     entries(): ArrayIterator<[number, number]>;
    540 
    541     /**
    542      * Returns an list of keys in the array
    543      */
    544     keys(): ArrayIterator<number>;
    545 
    546     /**
    547      * Returns an list of values in the array
    548      */
    549     values(): ArrayIterator<number>;
    550 }
    551 
    552 interface Float32ArrayConstructor {
    553     new (elements: Iterable<number>): Float32Array<ArrayBuffer>;
    554 
    555     /**
    556      * Creates an array from an array-like or iterable object.
    557      * @param elements An iterable object to convert to an array.
    558      */
    559     from(elements: Iterable<number>): Float32Array<ArrayBuffer>;
    560 
    561     /**
    562      * Creates an array from an array-like or iterable object.
    563      * @param elements An iterable object to convert to an array.
    564      * @param mapfn A mapping function to call on every element of the array.
    565      * @param thisArg Value of 'this' used to invoke the mapfn.
    566      */
    567     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float32Array<ArrayBuffer>;
    568 }
    569 
    570 interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
    571     [Symbol.iterator](): ArrayIterator<number>;
    572 
    573     /**
    574      * Returns an array of key, value pairs for every entry in the array
    575      */
    576     entries(): ArrayIterator<[number, number]>;
    577 
    578     /**
    579      * Returns an list of keys in the array
    580      */
    581     keys(): ArrayIterator<number>;
    582 
    583     /**
    584      * Returns an list of values in the array
    585      */
    586     values(): ArrayIterator<number>;
    587 }
    588 
    589 interface Float64ArrayConstructor {
    590     new (elements: Iterable<number>): Float64Array<ArrayBuffer>;
    591 
    592     /**
    593      * Creates an array from an array-like or iterable object.
    594      * @param elements An iterable object to convert to an array.
    595      */
    596     from(elements: Iterable<number>): Float64Array<ArrayBuffer>;
    597 
    598     /**
    599      * Creates an array from an array-like or iterable object.
    600      * @param elements An iterable object to convert to an array.
    601      * @param mapfn A mapping function to call on every element of the array.
    602      * @param thisArg Value of 'this' used to invoke the mapfn.
    603      */
    604     from<T>(elements: Iterable<T>, mapfn?: (v: T, k: number) => number, thisArg?: any): Float64Array<ArrayBuffer>;
    605 }
© notamitgamer • Site Built: 2026-07-22 07:33:49 UTC • git-mirror commit: b2c569f [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror