UNPKG

@diffusionstudio/core-v4

Version:

2D motion graphics and video rendering engine

45 lines (44 loc) 1.51 kB
/** * Convert an alpha value to hex * @param alpha A value between 0 and 1 * @returns Alpha as 2 digit hex * @example FF */ export declare function toHex(alpha: number): string; /** * Group an array of objects by the specified key */ export declare function groupBy<T extends {}, K extends keyof T>(arr: T[], key: K): Record<T[K], T[]>; /** * Split an array at the specified position */ export declare function splitAt<T>(list: any[] | string, index: number): T; /** * Generate a random value between two numbers */ export declare function randInt(min: number, max: number | undefined): number; /** * setTimeout async/await replacement */ export declare function sleep(ms: number): Promise<void>; /** * clip assert replacement for the browser * @example assert(true == false) */ export declare function assert(condition: any, message?: string): asserts condition; /** * Limit the number of times a function can be called * per interval, timeout is in milliseconds */ export declare function debounce(func: Function, timeout?: number): (...args: any[]) => void; /** * Move an element inside the provided array */ export declare function arraymove(arr: any[], fromIndex: number, toIndex: number): void; /** * Short unique id (not as secure as uuid 4 though) */ export declare function uid(): string | undefined; export declare function capitalize(str: string): string; export declare function clamp(t: number, a: number, b: number): number; export declare function assertNever(_: never): void;