@@ -5,44 +5,15 @@ import Debug from "./debug";
55
66import TLSProfiles from "../constants/TLSProfiles" ;
77
8- /**
9- * Test if two buffers are equal
10- *
11- * @export
12- * @param {Buffer } a
13- * @param {Buffer } b
14- * @returns {boolean } Whether the two buffers are equal
15- */
16- export function bufferEqual ( a : Buffer , b : Buffer ) : boolean {
17- if ( typeof a . equals === "function" ) {
18- return a . equals ( b ) ;
19- }
20-
21- if ( a . length !== b . length ) {
22- return false ;
23- }
24-
25- for ( let i = 0 ; i < a . length ; ++ i ) {
26- if ( a [ i ] !== b [ i ] ) {
27- return false ;
28- }
29- }
30- return true ;
31- }
32-
338/**
349 * Convert a buffer to string, supports buffer array
3510 *
36- * @param {* } value - The input value
37- * @param {string } encoding - string encoding
38- * @return {* } The result
3911 * @example
4012 * ```js
41- * var input = [Buffer.from('foo'), [Buffer.from('bar')]]
42- * var res = convertBufferToString(input, 'utf8')
13+ * const input = [Buffer.from('foo'), [Buffer.from('bar')]]
14+ * const res = convertBufferToString(input, 'utf8')
4315 * expect(res).to.eql(['foo', ['bar']])
4416 * ```
45- * @private
4617 */
4718export function convertBufferToString ( value : any , encoding ?: string ) {
4819 if ( value instanceof Buffer ) {
@@ -65,17 +36,14 @@ export function convertBufferToString(value: any, encoding?: string) {
6536/**
6637 * Convert a list of results to node-style
6738 *
68- * @param {Array } arr - The input value
69- * @return {Array } The output value
7039 * @example
7140 * ```js
72- * var input = ['a', 'b', new Error('c'), 'd']
73- * var output = exports.wrapMultiResult(input)
41+ * const input = ['a', 'b', new Error('c'), 'd']
42+ * const output = exports.wrapMultiResult(input)
7443 * expect(output).to.eql([[null, 'a'], [null, 'b'], [new Error('c')], [null, 'd'])
7544 * ```
76- * @private
7745 */
78- export function wrapMultiResult ( arr : any [ ] | null ) : any [ ] [ ] {
46+ export function wrapMultiResult ( arr : unknown [ ] | null ) : unknown [ ] [ ] {
7947 // When using WATCH/EXEC transactions, the EXEC will return
8048 // a null instead of an array
8149 if ( ! arr ) {
@@ -96,9 +64,6 @@ export function wrapMultiResult(arr: any[] | null): any[][] {
9664
9765/**
9866 * Detect if the argument is a int
99- *
100- * @param {string } value
101- * @return {boolean } Whether the value is a int
10267 * @example
10368 * ```js
10469 * > isInt('123')
@@ -122,8 +87,6 @@ export function isInt(value: any): value is string {
12287/**
12388 * Pack an array to an Object
12489 *
125- * @param {array } array
126- * @return {object }
12790 * @example
12891 * ```js
12992 * > packObject(['a', 'b', 'c', 'd'])
@@ -143,10 +106,6 @@ export function packObject(array: any[]): Record<string, any> {
143106
144107/**
145108 * Return a callback with timeout
146- *
147- * @param {function } callback
148- * @param {number } timeout
149- * @return {function }
150109 */
151110export function timeout ( callback : CallbackFunction , timeout : number ) {
152111 let timer : NodeJS . Timeout ;
@@ -163,9 +122,6 @@ export function timeout(callback: CallbackFunction, timeout: number) {
163122
164123/**
165124 * Convert an object to an array
166- *
167- * @param {object } obj
168- * @return {array }
169125 * @example
170126 * ```js
171127 * > convertObjectToArray({ a: '1' })
@@ -174,7 +130,7 @@ export function timeout(callback: CallbackFunction, timeout: number) {
174130 */
175131export function convertObjectToArray < T > (
176132 obj : Record < string , T >
177- ) : Array < string | T > {
133+ ) : ( string | T ) [ ] {
178134 const result = [ ] ;
179135 const keys = Object . keys ( obj ) ; // Object.entries requires node 7+
180136
@@ -186,16 +142,13 @@ export function convertObjectToArray<T>(
186142
187143/**
188144 * Convert a map to an array
189- *
190- * @param {Map } map
191- * @return {array }
192145 * @example
193146 * ```js
194147 * > convertMapToArray(new Map([[1, '2']]))
195148 * [1, '2']
196149 * ```
197150 */
198- export function convertMapToArray < K , V > ( map : Map < K , V > ) : Array < K | V > {
151+ export function convertMapToArray < K , V > ( map : Map < K , V > ) : ( K | V ) [ ] {
199152 const result : Array < K | V > = [ ] ;
200153 let pos = 0 ;
201154 map . forEach ( function ( value , key ) {
@@ -208,9 +161,6 @@ export function convertMapToArray<K, V>(map: Map<K, V>): Array<K | V> {
208161
209162/**
210163 * Convert a non-string arg to a string
211- *
212- * @param {* } arg
213- * @return {string }
214164 */
215165export function toArg ( arg : any ) : string {
216166 if ( arg === null || typeof arg === "undefined" ) {
@@ -298,7 +248,7 @@ export function parseURL(url: string) {
298248 return result ;
299249}
300250
301- interface ITLSOptions {
251+ interface TLSOptions {
302252 port : number ;
303253 host : string ;
304254 [ key : string ] : any ;
@@ -310,7 +260,7 @@ interface ITLSOptions {
310260 * @param {Object } options - the redis connection options
311261 * @return {Object }
312262 */
313- export function resolveTLSProfile ( options : ITLSOptions ) : ITLSOptions {
263+ export function resolveTLSProfile ( options : TLSOptions ) : TLSOptions {
314264 let tls = options ?. tls ;
315265
316266 if ( typeof tls === "string" ) tls = { profile : tls } ;
0 commit comments