/
Utils.ts
79 lines (65 loc) · 2.18 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { IEs3CheckKeyword } from "./Interfaces";
export function isSourceMapEnabled(options:any) {
if (options) {
return options.sourceMap !== false && options.sourcemap !== false;
}
return false;
}
// Need to mock this rather than rely on JavaScript String.prototype.padEnd() as it doesn't always
// exists in the build / test infrastructure
export function padEnd(input:string, len:number, fill:string) {
let value = input||"";
while (value.length < len) {
value += fill;
}
if (value.length > len) {
value = value.substring(0, len);
}
return value;
}
export function isNullOrUndefined(value: any): boolean
{
return value === undefined || value === null || typeof value === "undefined";
}
export function isNullOrWhitespace(value:string) {
if (value) {
return value.replace(/\s/g, "").length < 1;
}
return true;
}
export function isIgnore(id:string, keyword:IEs3CheckKeyword, isTransform:boolean) {
let result = false;
if (keyword.ignoreIds) {
for (let ignoreIdx in keyword.ignoreIds) {
let ignoreMatch = keyword.ignoreIds[ignoreIdx];
if (id && id.indexOf(ignoreMatch) !== -1) {
result = true;
break;
}
}
}
return result;
}
export function isIgnoreFuncMatch(funcMatch:string, keyword:IEs3CheckKeyword) {
let result = false;
if (funcMatch && keyword.ignoreFuncMatch) {
for (let ignoreIdx in keyword.ignoreFuncMatch) {
let ignoreMatch = keyword.ignoreFuncMatch[ignoreIdx];
if (ignoreMatch) {
if (typeof ignoreMatch === "string" && funcMatch.indexOf(ignoreMatch) !== -1) {
result = true;
break;
} else if (ignoreMatch instanceof RegExp) {
let match = ignoreMatch.exec(funcMatch);
if (match && match.length > 0) {
result = true;
break;
}
}
}
}
}
return result;
}