/// /** * A function that does nothing. Use it as an empty callback initializer. */ export declare type NilCallback = (err?: Error, val?: any) => void; export declare let nil: NilCallback; /** * A function that can be used to initialize an event callback. This function * does nothing so a callback will do */ export declare type INilEventCallback = () => void; export declare let nilEvent: INilEventCallback; /** * Takes an array of numbers and finds the closest value to the given * input number. * * Inspired by https://github.com/andreruffert/closest-number * * @param arr {number[]} array of numbers to search * @param num {number} the number value used as a reference to find * @returns {number} the number from arr that is closest to num */ export declare function closestNumber(arr: number[], num: number): number; /** * Generates a random integer between the two specified values. The value is * no lower than min and not equal to max (not inclusive). Do not use this * for cryptography. * * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random * * @param min {number} the smallest integer to use, inclusive * @param max {number} the largest integer to use, non inclusive * @returns {number} a pseudo random number */ export declare function getRandomInt(min: number, max: number): number; /** * Generates a random integer between the two specified values. The value is * no lower than min and less than or equal to max (inclusive). Do not use this * for cryptography. * * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random * * @param min {number} the smallest integer to use, inclusive * @param max {number} the largest integer to use, inclusive * @returns {number} a pseudo random number */ export declare function getRandomIntInclusive(min: number, max: number): number; /** * Retrieves a version 4 uuid. It can be with or without the dash characters. * @param nodash {boolean} if true, the dashes are removed, otherwise just a * v4 uuid is created. * @returns {string} a v4 uuid */ export declare function getUUID(nodash?: boolean): string; /** * Checks the environment to see if it is running under a browser environment * @return true if the environment is the browser, otherwise false. */ export declare function isBrowser(): boolean; /** * Checks the environment to see if it is running under nodejs. Note that * this can be unreliable if "process" is globally defined in the * environment by some other application (i.e. monkeypatching) * @return true if the environment is running under node, otherwise false */ export declare function isNode(): boolean; /** * Searchs an objects value list to find its associated key. It will return * the key of the first value found. * @param obj {any} - the object to search for a value * @param val {any} - the data to search for within the object * @return the key/value pair, otherwise null */ export declare function objFindKeyByValue(obj: any, val: any): any; /** * Searches an objects value list to see if it exists within the object. * If a key contains that value, then it returns true, otherwise false. * @param obj {any} - the object to search for a value * @param val {any} - the data to search for within the object * @return true if the value is found otherwise false */ export declare function objHasValue(obj: any, val: any): any; /** * Rounds a number to its nearest precision * @param n {number} - the number to round * @param precision {number} - the number of decimal places to preserve * @return the newly rounded number */ export declare function roundUp(n: number, precision?: number): number; /** * Takes a data buffer of output bytes, converts it to a string and then splits * it on newlines for output. By default it is just saved into a sanitized * array. If verbose is set to true, then the buffer it output to the console * line by line. * @param buffer {string | Buffer} - the output bytes to convert and print to log. * @param verbose=false {boolean} if true, then the sanitized output is sent to * the console. * @param log {console.log} the output logger to write the output when verbose. * @param encoding="utf8" {string} - the encoding type for a buffer input type * when it is coverted to a string. * @retuns {string[]} an array of string that represent the lines given with * the input buffer. */ export declare function sanitize(buffer: string | Buffer, verbose?: boolean, log?: { (message?: any, ...optionalParams: any[]): void; (message?: any, ...optionalParams: any[]): void; }, encoding?: string): string[];