/// import { defaults, noop, flatten } from "./lodash"; import Debug from "./debug"; /** * Test if two buffers are equal * * @export * @param {Buffer} a * @param {Buffer} b * @returns {boolean} Whether the two buffers are equal */ export declare function bufferEqual(a: Buffer, b: Buffer): boolean; /** * Convert a buffer to string, supports buffer array * * @param {*} value - The input value * @param {string} encoding - string encoding * @return {*} The result * @example * ```js * var input = [Buffer.from('foo'), [Buffer.from('bar')]] * var res = convertBufferToString(input, 'utf8') * expect(res).to.eql(['foo', ['bar']]) * ``` * @private */ export declare function convertBufferToString(value: any, encoding?: string): any; /** * Convert a list of results to node-style * * @param {Array} arr - The input value * @return {Array} The output value * @example * ```js * var input = ['a', 'b', new Error('c'), 'd'] * var output = exports.wrapMultiResult(input) * expect(output).to.eql([[null, 'a'], [null, 'b'], [new Error('c')], [null, 'd']) * ``` * @private */ export declare function wrapMultiResult(arr: any): any[]; /** * Detect the argument is a int * * @param {string} value * @return {boolean} Whether the value is a int * @example * ```js * > isInt('123') * true * > isInt('123.3') * false * > isInt('1x') * false * > isInt(123) * true * > isInt(true) * false * ``` * @private */ export declare function isInt(value: any): boolean; /** * Pack an array to an Object * * @param {array} array * @return {object} * @example * ```js * > packObject(['a', 'b', 'c', 'd']) * { a: 'b', c: 'd' } * ``` */ export declare function packObject(array: any): {}; /** * Return a callback with timeout * * @param {function} callback * @param {number} timeout * @return {function} */ export declare function timeout(callback: any, timeout: any): () => void; /** * Convert an object to an array * * @param {object} obj * @return {array} * @example * ```js * > convertObjectToArray({ a: '1' }) * ['a', '1'] * ``` */ export declare function convertObjectToArray(obj: any): any[]; /** * Convert a map to an array * * @param {Map} map * @return {array} * @example * ```js * > convertObjectToArray(new Map([[1, '2']])) * [1, '2'] * ``` */ export declare function convertMapToArray(map: Map): Array; /** * Convert a non-string arg to a string * * @param {*} arg * @return {string} */ export declare function toArg(arg: any): string; /** * Optimize error stack * * @param {Error} error - actually error * @param {string} friendlyStack - the stack that more meaningful * @param {string} filterPath - only show stacks with the specified path */ export declare function optimizeErrorStack(error: any, friendlyStack: any, filterPath: any): any; /** * Parse the redis protocol url * * @param {string} url - the redis protocol url * @return {Object} */ export declare function parseURL(url: any): any; /** * Get a random element from `array` * * @export * @template T * @param {T[]} array the array * @param {number} [from=0] start index * @returns {T} */ export declare function sample(array: T[], from?: number): T; /** * Shuffle the array using the Fisher-Yates Shuffle. * This method will mutate the original array. * * @export * @template T * @param {T[]} array * @returns {T[]} */ export declare function shuffle(array: T[]): T[]; /** * Error message for connection being disconnected */ export declare const CONNECTION_CLOSED_ERROR_MSG = "Connection is closed."; export declare function zipMap(keys: K[], values: V[]): Map; export { Debug, defaults, noop, flatten };