mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Remove tuple type
This commit is contained in:
parent
ae3cc10b03
commit
ad2df92a22
2 changed files with 0 additions and 204 deletions
|
@ -28,7 +28,6 @@ import type {
|
|||
PointBinding,
|
||||
FixedPointBinding,
|
||||
ExcalidrawFlowchartNodeElement,
|
||||
Tuple,
|
||||
} from "./types";
|
||||
|
||||
export const isInitializedImageElement = (
|
||||
|
@ -339,18 +338,3 @@ export const isBounds = (box: unknown): box is Bounds =>
|
|||
typeof box[1] === "number" &&
|
||||
typeof box[2] === "number" &&
|
||||
typeof box[3] === "number";
|
||||
|
||||
export const isTuple = <T, N extends number>(
|
||||
item: readonly T[],
|
||||
count: N,
|
||||
): item is Tuple<T, N> => item.length === count;
|
||||
|
||||
export const asTuple = <T, N extends number>(
|
||||
item: T[],
|
||||
count: N,
|
||||
): Tuple<T, N> | null => {
|
||||
if (isTuple(item, count)) {
|
||||
return item as Tuple<T, N>;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -412,191 +412,3 @@ export type NonDeletedSceneElementsMap = Map<
|
|||
export type ElementsMapOrArray =
|
||||
| readonly ExcalidrawElement[]
|
||||
| Readonly<ElementsMap>;
|
||||
|
||||
// Tuples are readonly, do not expose this interface!
|
||||
interface MutableTuple<T, N extends number> extends Array<T> {
|
||||
length: N;
|
||||
|
||||
/**
|
||||
* Reverses the elements in an array in place.
|
||||
* This method mutates the array and returns a reference to the same array.
|
||||
*/
|
||||
reverse(): MutableTuple<T, N>;
|
||||
/**
|
||||
* Sorts an array in place.
|
||||
* This method mutates the array and returns a reference to the same array.
|
||||
* @param compareFn Function used to determine the order of the elements. It is expected to return
|
||||
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
|
||||
* value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
|
||||
* ```ts
|
||||
* [11,2,22,1].sort((a, b) => a - b)
|
||||
* ```
|
||||
*/
|
||||
sort(compareFn?: (a: T, b: T) => number): this;
|
||||
/**
|
||||
* Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
|
||||
*/
|
||||
indexOf(searchElement: T, fromIndex?: N): N | -1;
|
||||
/**
|
||||
* Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.
|
||||
* @param searchElement The value to locate in the array.
|
||||
* @param fromIndex The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array.
|
||||
*/
|
||||
lastIndexOf(searchElement: T, fromIndex?: N): N | -1;
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
* @param predicate A function that accepts up to three arguments. The every method calls
|
||||
* the predicate function for each element in the array until the predicate returns a value
|
||||
* which is coercible to the Boolean value false, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
every<S extends T>(
|
||||
predicate: (
|
||||
value: T,
|
||||
index: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => value is S,
|
||||
thisArg?: any,
|
||||
): this is S[];
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
* @param predicate A function that accepts up to three arguments. The every method calls
|
||||
* the predicate function for each element in the array until the predicate returns a value
|
||||
* which is coercible to the Boolean value false, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
every(
|
||||
predicate: (value: T, index: number, array: MutableTuple<T, N>) => unknown,
|
||||
thisArg?: any,
|
||||
): boolean;
|
||||
/**
|
||||
* Determines whether the specified callback function returns true for any element of an array.
|
||||
* @param predicate A function that accepts up to three arguments. The some method calls
|
||||
* the predicate function for each element in the array until the predicate returns a value
|
||||
* which is coercible to the Boolean value true, or until the end of the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
||||
* If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
some(
|
||||
predicate: (value: T, index: number, array: MutableTuple<T, N>) => unknown,
|
||||
thisArg?: any,
|
||||
): boolean;
|
||||
/**
|
||||
* Performs the specified action for each element in an array.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(
|
||||
callbackfn: (value: T, index: number, array: MutableTuple<T, N>) => void,
|
||||
thisArg?: any,
|
||||
): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(
|
||||
callbackfn: (value: T, index: number, array: MutableTuple<T, N>) => U,
|
||||
thisArg?: any,
|
||||
): MutableTuple<U, N>;
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter<S extends T>(
|
||||
predicate: (
|
||||
value: T,
|
||||
index: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => value is S,
|
||||
thisArg?: any,
|
||||
): S[];
|
||||
/**
|
||||
* Returns the elements of an array that meet the condition specified in a callback function.
|
||||
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
filter(
|
||||
predicate: (value: T, index: number, array: MutableTuple<T, N>) => unknown,
|
||||
thisArg?: any,
|
||||
): T[];
|
||||
/**
|
||||
* 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.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduce(
|
||||
callbackfn: (
|
||||
previousValue: T,
|
||||
currentValue: T,
|
||||
currentIndex: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => T,
|
||||
): T;
|
||||
reduce(
|
||||
callbackfn: (
|
||||
previousValue: T,
|
||||
currentValue: T,
|
||||
currentIndex: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => T,
|
||||
initialValue: T,
|
||||
): T;
|
||||
/**
|
||||
* 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.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduce<U>(
|
||||
callbackfn: (
|
||||
previousValue: U,
|
||||
currentValue: T,
|
||||
currentIndex: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => 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.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduceRight(
|
||||
callbackfn: (
|
||||
previousValue: T,
|
||||
currentValue: T,
|
||||
currentIndex: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => T,
|
||||
): T;
|
||||
reduceRight(
|
||||
callbackfn: (
|
||||
previousValue: T,
|
||||
currentValue: T,
|
||||
currentIndex: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => T,
|
||||
initialValue: T,
|
||||
): T;
|
||||
/**
|
||||
* 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.
|
||||
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
|
||||
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
||||
*/
|
||||
reduceRight<U>(
|
||||
callbackfn: (
|
||||
previousValue: U,
|
||||
currentValue: T,
|
||||
currentIndex: number,
|
||||
array: MutableTuple<T, N>,
|
||||
) => U,
|
||||
initialValue: U,
|
||||
): U;
|
||||
}
|
||||
|
||||
export type Tuple<T, N extends number> = Readonly<MutableTuple<T, N>>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue