import clone from 'just-clone';
-import { Constants } from './internal';
+// import { Constants } from './internal';
+import { Constants } from './Constants';
import { WebSocketCloseEventStatusString } from '../types';
export class Utils {
}
public static isCFEnvironment(): boolean {
- return process.env.VCAP_APPLICATION !== undefined;
+ return !Utils.isNullOrUndefined(process.env.VCAP_APPLICATION);
}
public static isIterable<T>(obj: T): boolean {
}
public static isEmptyArray(object: unknown | unknown[]): boolean {
- if (Array.isArray(object) && object.length === 0) {
- return true;
- }
- return false;
+ return Array.isArray(object) && object.length === 0;
}
public static isNotEmptyArray(object: unknown | unknown[]): boolean {
- if (Array.isArray(object) && object.length > 0) {
- return true;
- }
- return false;
+ return Array.isArray(object) && object.length > 0;
}
public static isEmptyObject(obj: object): boolean {
* @param retryNumber - the number of retries that have already been attempted
* @returns delay in milliseconds
*/
- public static exponentialDelay(retryNumber = 0): number {
+ public static exponentialDelay(retryNumber = 0, maxDelayRatio = 0.2): number {
const delay = Math.pow(2, retryNumber) * 100;
- const randomSum = delay * 0.2 * Utils.secureRandom(); // 0-20% of the delay
+ const randomSum = delay * maxDelayRatio * Utils.secureRandom(); // 0-20% of the delay
return delay + randomSum;
}