-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathutils.ts
39 lines (33 loc) · 1012 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { IOptions } from "../declarations";
import { IUtils } from "./declarations";
import { injector } from "./yok";
export class Utils implements IUtils {
constructor(private $options: IOptions, private $logger: ILogger) {}
public getParsedTimeout(defaultTimeout: number): number {
let timeout = defaultTimeout;
if (this.$options.timeout) {
const parsedValue = parseInt(this.$options.timeout);
if (!isNaN(parsedValue) && parsedValue >= 0) {
timeout = parsedValue;
} else {
this.$logger.warn(
"Specify timeout in a number of seconds to wait. Default value: " +
timeout +
" seconds will be used."
);
}
}
return timeout;
}
public getMilliSecondsTimeout(defaultTimeout: number): number {
const timeout = this.getParsedTimeout(defaultTimeout);
return timeout * 1000;
}
}
export function capitalizeFirstLetter(value: string) {
if (!value) {
return "";
}
return value.charAt(0).toUpperCase() + value.slice(1);
}
injector.register("utils", Utils);