UNPKG

image-in-browser

Version:

Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)

137 lines (136 loc) 6.31 kB
/** @format */ import { Rational } from './rational.js'; import { TypedArray } from './typings.js'; /** * Abstract class containing utility methods for array operations. */ export declare abstract class ArrayUtils { /** * Copies a subarray from an Int8Array. * @param {Int8Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Int8Array} A new Int8Array containing the copied elements. */ static copyInt8(from: Int8Array, begin?: number, end?: number): Int8Array; /** * Copies a subarray from a Uint8Array. * @param {Uint8Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Uint8Array} A new Uint8Array containing the copied elements. */ static copyUint8(from: Uint8Array, begin?: number, end?: number): Uint8Array; /** * Copies a subarray from an Int16Array. * @param {Int16Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Int16Array} A new Int16Array containing the copied elements. */ static copyInt16(from: Int16Array, begin?: number, end?: number): Int16Array; /** * Copies a subarray from a Uint16Array. * @param {Uint16Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Uint16Array} A new Uint16Array containing the copied elements. */ static copyUint16(from: Uint16Array, begin?: number, end?: number): Uint16Array; /** * Copies a subarray from an Int32Array. * @param {Int32Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Int32Array} A new Int32Array containing the copied elements. */ static copyInt32(from: Int32Array, begin?: number, end?: number): Int32Array; /** * Copies a subarray from a Uint32Array. * @param {Uint32Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Uint32Array} A new Uint32Array containing the copied elements. */ static copyUint32(from: Uint32Array, begin?: number, end?: number): Uint32Array; /** * Copies a subarray from a Float32Array. * @param {Float32Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Float32Array} A new Float32Array containing the copied elements. */ static copyFloat32(from: Float32Array, begin?: number, end?: number): Float32Array; /** * Copies a subarray from a Float64Array. * @param {Float64Array} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {Float64Array} A new Float64Array containing the copied elements. */ static copyFloat64(from: Float64Array, begin?: number, end?: number): Float64Array; /** * Copies a subarray from a TypedArray. * @param {TypedArray} from - The source array. * @param {number} [begin] - The beginning index. * @param {number} [end] - The ending index. * @returns {TypedArray} A new TypedArray containing the copied elements. * @throws {LibError} If the array type is unknown. */ static copy(from: TypedArray, begin?: number, end?: number): TypedArray; /** * Copies a range of elements from one TypedArray to another. * @param {TypedArray} from - The source array. * @param {number} fromStart - The starting index in the source array. * @param {TypedArray} to - The destination array. * @param {number} toStart - The starting index in the destination array. * @param {number} length - The number of elements to copy. */ static copyRange<T extends TypedArray>(from: T, fromStart: number, to: T, toStart: number, length: number): void; /** * Fills an array with a specified value. * @param {number} length - The length of the array. * @param {T} value - The value to fill the array with. * @returns {T[]} A new array filled with the specified value. */ static fill<T>(length: number, value: T): T[]; /** * Generates an array using a provided function. * @param {number} length - The length of the array. * @param {(index: number) => T} func - The function to generate each element. * @returns {T[]} A new array generated by the provided function. */ static generate<T>(length: number, func: (index: number) => T): T[]; /** * Compares two arrays for equality. * @param {TypedArray | unknown[]} a1 - The first array. * @param {TypedArray | unknown[]} a2 - The second array. * @returns {boolean} True if the arrays are equal, false otherwise. */ static equals(a1: TypedArray | unknown[], a2: TypedArray | unknown[]): boolean; /** * Compares two arrays of Rational objects for equality. * @param {Rational[]} a1 - The first array. * @param {Rational[]} a2 - The second array. * @returns {boolean} True if the arrays are equal, false otherwise. */ static equalsRationalArray(a1: Rational[], a2: Rational[]): boolean; /** * Retrieves the numeric values from an enum. * @param {T} t - The enum object. * @returns {number[]} An array of numeric values from the enum. */ static getNumEnumValues<T extends object>(t: T): number[]; /** * Checks if an object is a numeric array or a TypedArray. * @param {unknown} obj - The object to check. * @returns {boolean} True if the object is a numeric array or a TypedArray, false otherwise. */ static isNumArrayOrTypedArray(obj: unknown): boolean; /** * Checks if an object is an array of Rational objects. * @param {unknown} obj - The object to check. * @returns {boolean} True if the object is an array of Rational objects, false otherwise. */ static isArrayOfRational(obj: unknown): boolean; }