source: trip-planner-front/node_modules/autoprefixer/lib/utils.js@ 1ad8e64

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

initial commit

  • Property mode set to 100644
File size: 3.3 KB
Line 
1"use strict";
2
3function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
4
5function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
7function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
9var list = require('postcss').list;
10
11module.exports = {
12 /**
13 * Throw special error, to tell beniary,
14 * that this error is from Autoprefixer.
15 */
16 error: function error(text) {
17 var err = new Error(text);
18 err.autoprefixer = true;
19 throw err;
20 },
21
22 /**
23 * Return array, that doesn’t contain duplicates.
24 */
25 uniq: function uniq(array) {
26 var filtered = [];
27
28 for (var _iterator = _createForOfIteratorHelperLoose(array), _step; !(_step = _iterator()).done;) {
29 var i = _step.value;
30
31 if (!filtered.includes(i)) {
32 filtered.push(i);
33 }
34 }
35
36 return filtered;
37 },
38
39 /**
40 * Return "-webkit-" on "-webkit- old"
41 */
42 removeNote: function removeNote(string) {
43 if (!string.includes(' ')) {
44 return string;
45 }
46
47 return string.split(' ')[0];
48 },
49
50 /**
51 * Escape RegExp symbols
52 */
53 escapeRegexp: function escapeRegexp(string) {
54 return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&');
55 },
56
57 /**
58 * Return regexp to check, that CSS string contain word
59 */
60 regexp: function regexp(word, escape) {
61 if (escape === void 0) {
62 escape = true;
63 }
64
65 if (escape) {
66 word = this.escapeRegexp(word);
67 }
68
69 return new RegExp("(^|[\\s,(])(" + word + "($|[\\s(,]))", 'gi');
70 },
71
72 /**
73 * Change comma list
74 */
75 editList: function editList(value, callback) {
76 var origin = list.comma(value);
77 var changed = callback(origin, []);
78
79 if (origin === changed) {
80 return value;
81 }
82
83 var join = value.match(/,\s*/);
84 join = join ? join[0] : ', ';
85 return changed.join(join);
86 },
87
88 /**
89 * Split the selector into parts.
90 * It returns 3 level deep array because selectors can be comma
91 * separated (1), space separated (2), and combined (3)
92 * @param {String} selector selector string
93 * @return {Array<Array<Array>>} 3 level deep array of split selector
94 * @see utils.test.js for examples
95 */
96 splitSelector: function splitSelector(selector) {
97 return list.comma(selector).map(function (i) {
98 return list.space(i).map(function (k) {
99 return k.split(/(?=\.|#)/g);
100 });
101 });
102 }
103};
Note: See TracBrowser for help on using the repository browser.