1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
|
20 |
|
21 |
|
22 | function arrayify(arg) {
|
23 | if (Array.isArray(arg)) {
|
24 | return arg;
|
25 | }
|
26 | else if (arg != undefined) {
|
27 | return [arg];
|
28 | }
|
29 | else {
|
30 | return [];
|
31 | }
|
32 | }
|
33 | exports.arrayify = arrayify;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | function objectify(arg) {
|
39 | if (typeof arg === "object" && arg != undefined) {
|
40 | return arg;
|
41 | }
|
42 | else {
|
43 | return {};
|
44 | }
|
45 | }
|
46 | exports.objectify = objectify;
|
47 | function hasOwnProperty(arg, key) {
|
48 | return Object.prototype.hasOwnProperty.call(arg, key);
|
49 | }
|
50 | exports.hasOwnProperty = hasOwnProperty;
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | function camelize(stringWithHyphens) {
|
56 | return stringWithHyphens.replace(/-(.)/g, function (_, nextLetter) { return nextLetter.toUpperCase(); });
|
57 | }
|
58 | exports.camelize = camelize;
|
59 | function isUpperCase(str) {
|
60 | return str === str.toUpperCase();
|
61 | }
|
62 | exports.isUpperCase = isUpperCase;
|
63 | function isLowerCase(str) {
|
64 | return str === str.toLowerCase();
|
65 | }
|
66 | exports.isLowerCase = isLowerCase;
|
67 |
|
68 |
|
69 |
|
70 | function dedent(strings) {
|
71 | var values = [];
|
72 | for (var _i = 1; _i < arguments.length; _i++) {
|
73 | values[_i - 1] = arguments[_i];
|
74 | }
|
75 | var fullString = strings.reduce(function (accumulator, str, i) { return "" + accumulator + values[i - 1] + str; });
|
76 |
|
77 | var match = fullString.match(/^[ \t]*(?=\S)/gm);
|
78 | if (match === null) {
|
79 |
|
80 | return fullString;
|
81 | }
|
82 |
|
83 | var indent = Math.min.apply(Math, match.map(function (el) { return el.length; }));
|
84 | var regexp = new RegExp("^[ \\t]{" + indent + "}", "gm");
|
85 | fullString = indent > 0 ? fullString.replace(regexp, "") : fullString;
|
86 | return fullString;
|
87 | }
|
88 | exports.dedent = dedent;
|
89 |
|
90 |
|
91 |
|
92 | function stripComments(content) {
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | var regexp = /("(?:[^\\\"]*(?:\\.)?)*")|('(?:[^\\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
|
100 | var result = content.replace(regexp, function (match, _m1, _m2, m3, m4) {
|
101 |
|
102 | if (m3 !== undefined) {
|
103 |
|
104 | return "";
|
105 | }
|
106 | else if (m4 !== undefined) {
|
107 |
|
108 | var length = m4.length;
|
109 | if (length > 2 && m4[length - 1] === "\n") {
|
110 | return m4[length - 2] === "\r" ? "\r\n" : "\n";
|
111 | }
|
112 | else {
|
113 | return "";
|
114 | }
|
115 | }
|
116 | else {
|
117 |
|
118 | return match;
|
119 | }
|
120 | });
|
121 | return result;
|
122 | }
|
123 | exports.stripComments = stripComments;
|
124 |
|
125 |
|
126 |
|
127 | function escapeRegExp(re) {
|
128 | return re.replace(/[.+*?|^$[\]{}()\\]/g, "\\$&");
|
129 | }
|
130 | exports.escapeRegExp = escapeRegExp;
|
131 | function arraysAreEqual(a, b, eq) {
|
132 | return a === b || a !== undefined && b !== undefined && a.length === b.length && a.every(function (x, idx) { return eq(x, b[idx]); });
|
133 | }
|
134 | exports.arraysAreEqual = arraysAreEqual;
|
135 |
|
136 | function find(inputs, getResult) {
|
137 | for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
|
138 | var element = inputs_1[_i];
|
139 | var result = getResult(element);
|
140 | if (result !== undefined) {
|
141 | return result;
|
142 | }
|
143 | }
|
144 | return undefined;
|
145 | }
|
146 | exports.find = find;
|
147 |
|
148 | function flatMap(inputs, getOutputs) {
|
149 | var out = [];
|
150 | for (var i = 0; i < inputs.length; i++) {
|
151 | out.push.apply(out, getOutputs(inputs[i], i));
|
152 | }
|
153 | return out;
|
154 | }
|
155 | exports.flatMap = flatMap;
|
156 |
|
157 | function mapDefined(inputs, getOutput) {
|
158 | var out = [];
|
159 | for (var _i = 0, inputs_2 = inputs; _i < inputs_2.length; _i++) {
|
160 | var input = inputs_2[_i];
|
161 | var output = getOutput(input);
|
162 | if (output !== undefined) {
|
163 | out.push(output);
|
164 | }
|
165 | }
|
166 | return out;
|
167 | }
|
168 | exports.mapDefined = mapDefined;
|
169 | function readBufferWithDetectedEncoding(buffer) {
|
170 | switch (detectBufferEncoding(buffer)) {
|
171 | case "utf8":
|
172 | return buffer.toString();
|
173 | case "utf8-bom":
|
174 | return buffer.toString("utf-8", 2);
|
175 | case "utf16le":
|
176 | return buffer.toString("utf16le", 2);
|
177 | case "utf16be":
|
178 |
|
179 | var len = buffer.length & ~1;
|
180 |
|
181 | for (var i = 0; i < len; i += 2) {
|
182 | var temp = buffer[i];
|
183 | buffer[i] = buffer[i + 1];
|
184 | buffer[i + 1] = temp;
|
185 | }
|
186 | return buffer.toString("utf16le", 2);
|
187 | }
|
188 | }
|
189 | exports.readBufferWithDetectedEncoding = readBufferWithDetectedEncoding;
|
190 | function detectBufferEncoding(buffer, length) {
|
191 | if (length === void 0) { length = buffer.length; }
|
192 | if (length < 2) {
|
193 | return "utf8";
|
194 | }
|
195 | switch (buffer[0]) {
|
196 | case 0xEF:
|
197 | if (buffer[1] === 0xBB && length >= 3 && buffer[2] === 0xBF) {
|
198 | return "utf8-bom";
|
199 | }
|
200 | break;
|
201 | case 0xFE:
|
202 | if (buffer[1] === 0xFF) {
|
203 | return "utf16be";
|
204 | }
|
205 | break;
|
206 | case 0xFF:
|
207 | if (buffer[1] === 0xFE) {
|
208 | return "utf16le";
|
209 | }
|
210 | }
|
211 | return "utf8";
|
212 | }
|
213 | exports.detectBufferEncoding = detectBufferEncoding;
|
214 |
|
215 | function denormalizeWinPath(path) {
|
216 | return path.replace(/\\/g, "/");
|
217 | }
|
218 | exports.denormalizeWinPath = denormalizeWinPath;
|