UNPKG

fallout-utility

Version:
37 lines (36 loc) 1.41 kB
import { JSONEncodable, RestOrArray } from '../types'; /** * Normalize an array given from a rest param * @param array Rest data */ export declare function normalizeArray<T>(array: RestOrArray<T>): T[]; /** * Get random key from array or properties of an object * @param obj Get random key from this object */ export declare function getRandomKey<T extends unknown[]>(obj: T): T[0]; export declare function getRandomKey<T extends {}>(obj: T): keyof T; /** * Slice array values into chunks * @param arr Array to slice * @param chunkSize Chunk size */ export declare function sliceIntoChunks<T>(arr: T[], chunkSize: number): T[][]; /** * Replace values inside an object recursively * @param object Object to replace values from * @param find String to replace * @param replace Replacement string */ export declare function recursiveObjectReplaceValues<T extends string | {} | []>(object: T, find: string[], replace: string[]): T; export declare function recursiveObjectReplaceValues<T extends string | {} | []>(object: T, find: string, replace: string): T; /** * Check if an object is from a class * @param object Object to check */ export declare function isClass<T>(object: any): object is T; /** * Checks if an object is JSON encodable or not * @param maybeEncodable Object to check */ export declare function isJSONEncodable<T>(maybeEncodable: any): maybeEncodable is JSONEncodable<T>;