UNPKG

@cute-dw/core

Version:

This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need

87 lines (86 loc) 4.37 kB
import { List } from "../collections/List"; import { Compare } from "./function/Compare"; import { Observable } from "rxjs"; export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; /** * This class consists exclusively of static methods that operate on or return arrays */ export declare class Arrays { /** * Returns a list object initialized with specified values * @param args Initial values by which the list will be backed * @returns A new list object that contains the specifies values * @static */ static asList<T>(...args: T[]): List<T>; /** * Searches the specified array for the specified value using the binary search algorithm. The array must be sorted * prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with * the specified value, there is no guarantee which one will be found. * @param sortedArray The array to be searched * @param key The value to be searched for * @param compareFn Optional compare function * @returns Index of the search key, if it is contained in the array; otherwise -1 * @static * @since 0.5.0 */ static binarySearch<T>(sortedArray: Array<T>, key: T, compareFn?: Compare<T>): number; /** * Returns `true` if the two specified arrays are deeply equal to one another. * @param a1 one array to be tested for equality * @param a2 the other array to be tested for equality * @returns `true` if the two arrays are equal * @since 0.5.0 */ static deepEquals<T = any>(a1: Array<T> | null, a2: Array<T> | null): boolean; /** * Returns _true_ if the two specified arrays of chars are _equal_ to one another. Two arrays are considered equal if both arrays contain the same * number of elements, and all corresponding pairs of elements in the two arrays are equal. In other words, two arrays are equal if they contain * the same elements in the same order. Also, two array references are considered equal if both are _null_. * @param arr1 one array to be tested for equality * @param arr2 the other array to be tested for equality * @returns _true_ if the two arrays are equal * @since 0.5.0 */ static equals<T = any>(arr1: Array<T>, arr2: Array<T>): boolean; /** * Pads the source array with a given `filler` value (possibly repeated) so that the array's size reaches a given length `len`. * Filling is performed from the end of the source array. * @param arr Source array * @param len Required minimum size of the source array * @param filler The value to be filled in * @returns Source array with modified length * @static * @since 0.5.0 * @see {@link padStart} */ static padEnd<T>(arr: T[], len: number, filler: T): Array<T>; /** * Pads the source array with a given `filler` value (possibly repeated) so that the array's size reaches a given length `len`. * Filling is performed from the start of the source array. * @param arr Source array * @param len Required minimum size of the source array * @param filler The value to be filled in * @returns Source array with modified length * @static * @since 0.5.0 * @see {@link padEnd} */ static padStart<T>(arr: T[], len: number, filler: T): Array<T>; /** * Copies the specified array, truncating or padding with null characters (if necessary), so the copy has the specified length * @param arr The array to be copied * @param newLength The length of the copy to be returned * @returns a copy of the original array, truncated or padded with null characters to obtain the specified length * @static * @since 0.5.0 */ static copyOf<T>(arr: T[], newLength?: number): Array<T | null>; /** * Returns a sequential `Observable` object with the specified array as its source * @param arr The array, assumed to be unmodified during use * @returns An Observable for the array `arr` * @since 0.5.0 */ static stream<T>(arr: T[]): Observable<T>; }