@uploadx/core
Version:
Node.js resumable upload middleware
41 lines (40 loc) • 1.59 kB
TypeScript
export declare const pick: <T, K extends keyof T>(obj: T, whitelist: K[]) => Pick<T, K>;
export declare const uid: () => string;
export declare function md5(str: string): string;
/**
* FNV1A32 hash
*/
export declare function fnv(str: string): string;
/**
* FNV1A64 hash
*/
export declare function fnv64(str: string): string;
export declare function mapValues<T>(object: Record<string, any>, func: (value: any) => T): Record<string, T>;
export declare function isEqual(a: object, b: object, ...keysToIgnore: string[]): boolean;
export declare function isNumber(x?: unknown): x is number;
export declare function isRecord(x: unknown): x is Record<any, any>;
export declare function extendObject<T extends Record<any, any>>(target: T, ...sources: Partial<T[]>): T;
/**
* Convert a human-readable duration to ms
*/
export declare function toMilliseconds(value: string | number | undefined): number | undefined;
/**
* Convert a human-readable duration to seconds
*/
export declare function toSeconds(value: string | number): number | undefined;
/**
* Returns a first element of an array
*/
export declare function getFirstOne<T>(val: T[]): T;
/**
* Returns a last element of an array
*/
export declare function getLastOne<T>(val: T[]): T;
/**
* Returns a function that caches the result of func
* @param fn - function to be called
*/
export declare const memoize: <T, K>(fn: (arg: T) => K) => ((arg: T) => K);
export declare const hash: (arg: string) => string;
export declare const toBoolean: (val?: unknown) => boolean;
export declare function durationToMs(input: string): number;