@diffusionstudio/core-v4
Version:
A fast, browser based video compositing engine powered by WebCodecs
42 lines (41 loc) • 1.55 kB
TypeScript
/**
* 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, 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>;
/**
* 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;
export declare function capitalize(str: string): string;
export declare function clamp(t: number, a: number, b: number): number;
export declare function assertNever(_: never): void;
export declare function assert(condition: any, message?: string): asserts condition;
export declare class AsyncMutex {
currentPromise: Promise<void>;
acquire(): Promise<() => void>;
}
export declare const binarySearchLessOrEqual: <T>(arr: T[], key: number, valueGetter: (x: T) => number) => number;