Triplettype
Three ordered gem colours composing one falling triplet.
Import it
import type { Triplet } from "@johnmorrisdotca/houseki/falling-triplets";
Definition
type Triplet = readonly [
Colour,
Colour,
Colour
];
Members
| Name | Type | Description |
|---|---|---|
0 | Colour | |
1 | Colour | |
2 | Colour | |
length | 3 | |
toString | (): string | Returns a string representation of an array. |
toLocaleString | (): string
(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string | Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. |
concat | (...items: ConcatArray<Colour>[]): Colour[]
(...items: (Colour | ConcatArray<Colour>)[]): Colour[] | Combines two or more arrays. |
join | (separator?: string): string | Adds all the elements of an array separated by the specified separator string. |
slice | (start?: number, end?: number): Colour[] | Returns a section of an array. |
indexOf | (searchElement: Colour, fromIndex?: number): number | Returns the index of the first occurrence of a value in an array. |
lastIndexOf | (searchElement: Colour, fromIndex?: number): number | Returns the index of the last occurrence of a specified value in an array. |
every | <S extends Colour>(predicate: (value: Colour, index: number, array: readonly Colour[]) => value is S, thisArg?: any): this is readonly S[]
(predicate: (value: Colour, index: number, array: readonly Colour[]) => unknown, thisArg?: any): boolean | Determines whether all the members of an array satisfy the specified test. |
some | (predicate: (value: Colour, index: number, array: readonly Colour[]) => unknown, thisArg?: any): boolean | Determines whether the specified callback function returns true for any element of an array. |
forEach | (callbackfn: (value: Colour, index: number, array: readonly Colour[]) => void, thisArg?: any): void | Performs the specified action for each element in an array. |
map | <U>(callbackfn: (value: Colour, index: number, array: readonly Colour[]) => U, thisArg?: any): U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
filter | <S extends Colour>(predicate: (value: Colour, index: number, array: readonly Colour[]) => value is S, thisArg?: any): S[]
(predicate: (value: Colour, index: number, array: readonly Colour[]) => unknown, thisArg?: any): Colour[] | Returns the elements of an array that meet the condition specified in a callback function. |
reduce | (callbackfn: (previousValue: Colour, currentValue: Colour, currentIndex: number, array: readonly Colour[]) => Colour): Colour
(callbackfn: (previousValue: Colour, currentValue: Colour, currentIndex: number, array: readonly Colour[]) => Colour, initialValue: Colour): Colour
<U>(callbackfn: (previousValue: U, currentValue: Colour, currentIndex: number, array: readonly Colour[]) => U, initialValue: U): U | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
reduceRight | (callbackfn: (previousValue: Colour, currentValue: Colour, currentIndex: number, array: readonly Colour[]) => Colour): Colour
(callbackfn: (previousValue: Colour, currentValue: Colour, currentIndex: number, array: readonly Colour[]) => Colour, initialValue: Colour): Colour
<U>(callbackfn: (previousValue: U, currentValue: Colour, currentIndex: number, array: readonly Colour[]) => U, initialValue: U): U | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
find | <S extends Colour>(predicate: (value: Colour, index: number, obj: readonly Colour[]) => value is S, thisArg?: any): S | undefined
(predicate: (value: Colour, index: number, obj: readonly Colour[]) => unknown, thisArg?: any): Colour | undefined | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
findIndex | (predicate: (value: Colour, index: number, obj: readonly Colour[]) => unknown, thisArg?: any): number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
entries | (): ArrayIterator<[number, Colour]> | Returns an iterable of key, value pairs for every entry in the array |
keys | (): ArrayIterator<number> | Returns an iterable of keys in the array |
values | (): ArrayIterator<Colour> | Returns an iterable of values in the array |
includes | (searchElement: Colour, fromIndex?: number): boolean | Determines whether an array includes a certain element, returning true or false as appropriate. |
flatMap | <U, This = undefined>(callback: (this: This, value: Colour, index: number, array: Colour[]) => U | readonly U[], thisArg?: This | undefined): U[] | Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. |
flat | <A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[] | Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. |
at | (index: number): Colour | undefined | Returns the item located at the specified index. |
Examples
import type { Triplet } from "@johnmorrisdotca/houseki/falling-triplets";
const value: Triplet = ["red","green","blue"];
console.log(value == null ? value : typeof value === "object" ? Object.keys(value).slice(0,6) : value);[ '0', '1', '2' ]What it prints (run when this page was built)