UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

16 lines (14 loc) 766 B
/** * This should only be used for defining generics which extend any kind of JS * array under the hood, this includes arrays *AND* tuples (of the form [x, y], * and of the form [x, ...y[]], etc...), and their readonly equivalent. This * allows us to be more inclusive to what functions can process. * * @example * function map<T extends IterableContainer>(items: T) { ... } * * We would've named this `ArrayLike`, but that's already used by typescript... * @see This was inspired by the type-definition of Promise.all (https://github.com/microsoft/TypeScript/blob/1df5717b120cddd325deab8b0f2b2c3eecaf2b01/src/lib/es2015.promise.d.ts#L21) */ type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly []; export type { IterableContainer as I };