1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var path = require("path");
|
4 | var Utils;
|
5 | (function (Utils) {
|
6 | function exists(list, predicate) {
|
7 | if (list !== undefined) {
|
8 | for (var i = 0; i < list.length; i++) {
|
9 | var obj = list[i];
|
10 | if (predicate(obj)) {
|
11 | return true;
|
12 | }
|
13 | }
|
14 | }
|
15 | return false;
|
16 | }
|
17 | Utils.exists = exists;
|
18 | function contains(list, element) {
|
19 | return exists(list, function (item) {
|
20 | return item === element;
|
21 | });
|
22 | }
|
23 | Utils.contains = contains;
|
24 | function removeAll(source, elementsToRemove) {
|
25 | if (source === undefined || source.length === 0) {
|
26 | return [];
|
27 | }
|
28 | if (elementsToRemove === undefined || elementsToRemove.length === 0) {
|
29 | return source.slice();
|
30 | }
|
31 | return source.filter(function (sourceElement) {
|
32 | return !contains(elementsToRemove, sourceElement);
|
33 | });
|
34 | }
|
35 | Utils.removeAll = removeAll;
|
36 | function remove(source, elementToRemove) {
|
37 | return removeAll(source, [elementToRemove]);
|
38 | }
|
39 | Utils.remove = remove;
|
40 | function trimTo(source, maxLength) {
|
41 | if (source === undefined) {
|
42 | return '';
|
43 | }
|
44 | if (source.length <= maxLength) {
|
45 | return source;
|
46 | }
|
47 | return source.substr(0, maxLength - 2) + '...';
|
48 | }
|
49 | Utils.trimTo = trimTo;
|
50 | function absolutePath(relativePath) {
|
51 | return path.resolve(relativePath).replace(/\\/g, '/');
|
52 | }
|
53 | Utils.absolutePath = absolutePath;
|
54 | function fileBasename(relativePath) {
|
55 | return path.basename(relativePath);
|
56 | }
|
57 | Utils.fileBasename = fileBasename;
|
58 | })(Utils = exports.Utils || (exports.Utils = {}));
|
59 |
|
\ | No newline at end of file |