UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

45 lines (44 loc) 3.08 kB
import type { TypedArray } from 'three'; export type ArrayToItemFunction<T> = (array: Array<T>) => T; export declare function range(start: number, end: number, step: number, target: number[]): number[]; export declare function rangeWithEnd(end: number): number[]; export declare function rangeStartEnd(start: number, end: number): number[]; export declare function arrayUniq<T>(array: Array<T>, target: Array<T>): Array<T>; export declare function sampleIndex(array: Array<any>, seed: number): number; export declare function sample<T>(array: Array<T>, seed: number): T | undefined; export declare function spliceSample<T>(array: Array<T>, seed: number): T | undefined; export declare function uniqWithoutPreservingOrder<T>(array: Array<T>, target: Array<T>): Array<T>; export declare function arrayCompact<T>(array: Readonly<Array<T | null | undefined>>, target: Array<T>): Array<T>; export declare function arrayMin<T>(array: Array<T>): T; export declare function arrayMax<T>(array: Array<T>): T; export declare function arraySum(array: number[]): number; export declare function arrayChunk<T>(array: Array<T>, chunkSize: number): Array<Array<T>>; export declare function arrayUnion<T>(array0: Array<T>, array1: Array<T>, target: Array<T>): Array<T>; export declare function arrayIntersection<T>(array0: Array<T>, array1: Array<T>, target: Array<T>): Array<T>; export declare function arrayDifference<T>(array0: Array<T>, array1: Array<T>, target: Array<T>): Array<T>; export declare function arrayXOR<T>(array0: Array<T>, array1: Array<T>, target: Array<T>): Array<T>; export declare function arrayToSet<T>(array: Array<T>, target: Set<T>): Set<T>; export declare function arrayIsEqual<T extends number | string>(array0: Array<T>, array1: Array<T>): boolean; export declare function arraySortBy<T, K extends number | string>(array: Array<T>, callback: (e: T) => K): Array<T>; export declare function arrayShallowClone<T>(array: Array<T>): Array<T>; export declare function arrayMap<T, U>(array: Readonly<Array<T>>, callback: (e: T) => U, target: Array<U>): Array<U>; export declare function arrayAverage(array: number[]): number; export declare class ArrayUtils { static shallowClone: typeof arrayShallowClone; static min: typeof arrayMin; static max: typeof arrayMax; static sum: typeof arraySum; static compact: typeof arrayCompact; static uniq: typeof arrayUniq; static uniqWithoutPreservingOrder: typeof uniqWithoutPreservingOrder; static chunk: typeof arrayChunk; static union: typeof arrayUnion; static intersection: typeof arrayIntersection; static toSet: typeof arrayToSet; static isEqual: typeof arrayIsEqual; static sortBy: typeof arraySortBy; static range: typeof range; } export declare function arrayPushItems<T>(srcArray: Readonly<Array<T>>, target: Array<T>): void; export declare function arrayCopy<T>(srcArray: Readonly<Array<T> | ArrayLike<T>>, targetArray: Array<T>): void; export declare function typedArrayCopy<T1 extends TypedArray, T2 extends TypedArray>(srcArray: Readonly<T1>, targetArray: T2): T2;