/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
///
export {};
type IteratorZipShortestOptions = {
/**
* Stops when any input is exhausted.
*/
mode?: "shortest" | undefined;
};
type IteratorZipLongestOptions = {
/**
* Continues until every input is exhausted.
*/
mode: "longest";
/**
* Values used when an input is exhausted before the others.
*/
padding?: (T & object) | undefined;
};
type IteratorZipStrictOptions = {
/**
* Requires every input to yield the same number of values.
* If not, a `TypeError` will be thrown when an input is exhausted before others.
*/
mode: "strict";
};
type IteratorZipOptions =
| IteratorZipShortestOptions
| IteratorZipLongestOptions
| IteratorZipStrictOptions;
type IteratorInput = (Iterable | Iterator) & object;
type IteratorYield = T extends IteratorInput ? U : never;
type IteratorZipKey = K extends number ? K | `${K}` | (number extends K ? "NaN" | "Infinity" | "-Infinity" : never)
: K extends `${infer N extends number}` ? `${N}` extends K ? K | N : K : K;
type IteratorZipDefaultPadding = {
readonly [K in keyof T]?: IteratorYield | undefined;
};
type IteratorZipPaddingKeys = keyof {
[K in keyof T as {} extends Pick ? never : IteratorZipKey]: unknown;
};
type IteratorZipValue =
| IteratorYield
| (TPadding extends unknown ? TPadding[IteratorZipKey & keyof TPadding] | (K extends "NaN" | "Infinity" | "-Infinity" ? TPadding[number & keyof TPadding] : never) : never)
| (IteratorZipKey extends IteratorZipPaddingKeys ? never : TExtra);
type IteratorZipResult = {
-readonly [K in keyof T]: IteratorZipValue;
};
type IteratorZipKeyedInput = {
[K in T extends unknown ? keyof T : never]?: IteratorInput | undefined;
};
type IteratorZipKeyedResult = T extends Partial> ? keyof T extends never ? Record : never
: { -readonly [K in keyof T as undefined extends T[K] ? never : K]: IteratorZipValue; } &
{ -readonly [K in keyof T as undefined extends T[K] ? T[K] extends undefined ? never : K : never]?: IteratorZipValue; };
declare global {
interface IteratorObject {
/**
* Creates an iterator whose values are arrays containing successive values from this iterator.
* @param chunkSize The maximum number of values in each array.
*/
chunks(chunkSize: number): IteratorObject;
/**
* Creates a string by concatenating the values of this iterator, separated by the specified separator.
* `null` and `undefined` values contribute an empty string.
* @param separator A string used to separate values. If omitted, a comma is used.
*/
join(separator?: string): string;
/**
* Determines whether this iterator yields the specified value using SameValueZero comparison.
* @param searchElement The value to locate.
* @param skippedElements The number of values to skip before searching.
*/
includes(searchElement: T, skippedElements?: number): boolean;
}
interface IteratorConstructor {
/**
* Creates an iterator whose values are arrays containing values yielded at the same position by each input iterator or iterable.
* @param iterables An iterable of iterators or iterables to zip.
* @param options Controls how differing input lengths are handled.
*/
zip(iterables: readonly [], options?: IteratorZipOptions & object>): IteratorObject;
/**
* Creates an iterator whose values are arrays containing values yielded at the same position by each input iterator or iterable.
* @param iterables An iterable of iterators or iterables to zip.
* @param options Controls how differing input lengths are handled.
*/
zip[] | []>(iterables: T, options?: IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject, undefined, unknown>;
zip[] | [], TPadding extends readonly unknown[] | []>(iterables: T, options: IteratorZipLongestOptions & { padding: TPadding; }): IteratorObject, undefined, unknown>;
zip[] | [], TPadding extends readonly unknown[] | [] = IteratorZipDefaultPadding>(iterables: T, options?: IteratorZipOptions): IteratorObject>, undefined, unknown>;
/**
* Creates an iterator whose values are arrays containing values yielded at the same position by each input iterator or iterable.
* @param iterables An iterable of iterators or iterables to zip.
* @param options Controls how differing input lengths are handled.
*/
zip>(iterables: Iterable & object, options?: IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject[], undefined, unknown>;
zip, TPadding = IteratorYield>(iterables: Iterable & object, options?: IteratorZipOptions & object>): IteratorObject<(IteratorYield | TPadding | undefined)[], undefined, unknown>;
/**
* Creates an iterator whose values are objects containing values yielded at the same position by each iterator or iterable in the input object.
* @param iterables An object whose enumerable own properties contain iterators or iterables to zip. Undefined values are ignored.
* @param options Controls how differing input lengths are handled.
*/
zipKeyed(iterables: T & IteratorZipKeyedInput, options?: IteratorZipShortestOptions | IteratorZipStrictOptions): IteratorObject, undefined, unknown>;
zipKeyed(iterables: T & IteratorZipKeyedInput, options: IteratorZipLongestOptions & { padding: TPadding; }): IteratorObject, undefined, unknown>;
zipKeyed>(iterables: T & IteratorZipKeyedInput, options?: IteratorZipOptions): IteratorObject>, undefined, unknown>;
/**
* Accepts objects whose types include inherited or non-enumerable properties.
* Property ownership and enumerability are not represented in object types, so the result values are unknown.
* Iterator records use the preceding overloads to preserve their inferred result types.
*/
zipKeyed(iterables: T & ([T] extends [IteratorZipKeyedInput] ? never : unknown), options?: IteratorZipOptions