source: trip-planner-front/node_modules/less/lib/less/utils.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.flattenArray = exports.merge = exports.copyOptions = exports.defaults = exports.clone = exports.copyArray = exports.getLocation = void 0;
4var tslib_1 = require("tslib");
5/* jshint proto: true */
6var Constants = tslib_1.__importStar(require("./constants"));
7var copy_anything_1 = require("copy-anything");
8function getLocation(index, inputStream) {
9 var n = index + 1;
10 var line = null;
11 var column = -1;
12 while (--n >= 0 && inputStream.charAt(n) !== '\n') {
13 column++;
14 }
15 if (typeof index === 'number') {
16 line = (inputStream.slice(0, index).match(/\n/g) || '').length;
17 }
18 return {
19 line: line,
20 column: column
21 };
22}
23exports.getLocation = getLocation;
24function copyArray(arr) {
25 var i;
26 var length = arr.length;
27 var copy = new Array(length);
28 for (i = 0; i < length; i++) {
29 copy[i] = arr[i];
30 }
31 return copy;
32}
33exports.copyArray = copyArray;
34function clone(obj) {
35 var cloned = {};
36 for (var prop in obj) {
37 if (obj.hasOwnProperty(prop)) {
38 cloned[prop] = obj[prop];
39 }
40 }
41 return cloned;
42}
43exports.clone = clone;
44function defaults(obj1, obj2) {
45 var newObj = obj2 || {};
46 if (!obj2._defaults) {
47 newObj = {};
48 var defaults_1 = copy_anything_1.copy(obj1);
49 newObj._defaults = defaults_1;
50 var cloned = obj2 ? copy_anything_1.copy(obj2) : {};
51 Object.assign(newObj, defaults_1, cloned);
52 }
53 return newObj;
54}
55exports.defaults = defaults;
56function copyOptions(obj1, obj2) {
57 if (obj2 && obj2._defaults) {
58 return obj2;
59 }
60 var opts = defaults(obj1, obj2);
61 if (opts.strictMath) {
62 opts.math = Constants.Math.PARENS;
63 }
64 // Back compat with changed relativeUrls option
65 if (opts.relativeUrls) {
66 opts.rewriteUrls = Constants.RewriteUrls.ALL;
67 }
68 if (typeof opts.math === 'string') {
69 switch (opts.math.toLowerCase()) {
70 case 'always':
71 opts.math = Constants.Math.ALWAYS;
72 break;
73 case 'parens-division':
74 opts.math = Constants.Math.PARENS_DIVISION;
75 break;
76 case 'strict':
77 case 'parens':
78 opts.math = Constants.Math.PARENS;
79 break;
80 default:
81 opts.math = Constants.Math.PARENS;
82 }
83 }
84 if (typeof opts.rewriteUrls === 'string') {
85 switch (opts.rewriteUrls.toLowerCase()) {
86 case 'off':
87 opts.rewriteUrls = Constants.RewriteUrls.OFF;
88 break;
89 case 'local':
90 opts.rewriteUrls = Constants.RewriteUrls.LOCAL;
91 break;
92 case 'all':
93 opts.rewriteUrls = Constants.RewriteUrls.ALL;
94 break;
95 }
96 }
97 return opts;
98}
99exports.copyOptions = copyOptions;
100function merge(obj1, obj2) {
101 for (var prop in obj2) {
102 if (obj2.hasOwnProperty(prop)) {
103 obj1[prop] = obj2[prop];
104 }
105 }
106 return obj1;
107}
108exports.merge = merge;
109function flattenArray(arr, result) {
110 if (result === void 0) { result = []; }
111 for (var i = 0, length_1 = arr.length; i < length_1; i++) {
112 var value = arr[i];
113 if (Array.isArray(value)) {
114 flattenArray(value, result);
115 }
116 else {
117 if (value !== undefined) {
118 result.push(value);
119 }
120 }
121 }
122 return result;
123}
124exports.flattenArray = flattenArray;
125//# sourceMappingURL=utils.js.map
Note: See TracBrowser for help on using the repository browser.