@deepkit/core
Version:
Deepkit core library
38 lines (37 loc) • 999 B
TypeScript
/**
* @public
*/
export declare function arrayHasItem<T>(array: T[], item: T): boolean;
/**
* Clears the array so its empty. Returns the amount of removed items.
*
* @public
*/
export declare function arrayClear<T>(array: T[]): number;
/**
* Removes on particular item by reference of an array.
*
* @public
*/
export declare function arrayRemoveItem<T>(array: T[], item: T): boolean;
/**
* Moves a particular item in an array up or down (move>0=down, move<0=up).
* Changes the array itself.
*
* ```typescript
* const array = ['a', 'b', 'c'];
*
* arrayMoveItem(array, 'a', +1); //['b', 'a', 'c']
* arrayMoveItem(array, 'a', -1); //['a', 'b', 'c']
*
* arrayMoveItem(array, 'b', -1); //['b', 'a', 'c']
* arrayMoveItem(array, 'b', +1); //['a', 'c', 'b']
*
* arrayMoveItem(array, 'c', -1); //['b', 'c', 'b']
* arrayMoveItem(array, 'c', +1); //['a', 'b', 'c']
*
* ```
*
* @public
*/
export declare function arrayMoveItem<A extends T[], T>(array: A, item: T, move: number): A;