1 | "use strict";
|
2 |
|
3 | var list = require('postcss').list;
|
4 |
|
5 | module.exports = {
|
6 | |
7 |
|
8 |
|
9 |
|
10 | error: function error(text) {
|
11 | var err = new Error(text);
|
12 | err.autoprefixer = true;
|
13 | throw err;
|
14 | },
|
15 |
|
16 | |
17 |
|
18 |
|
19 | uniq: function uniq(array) {
|
20 | var filtered = [];
|
21 |
|
22 | for (var _iterator = array, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
23 | var _ref;
|
24 |
|
25 | if (_isArray) {
|
26 | if (_i >= _iterator.length) break;
|
27 | _ref = _iterator[_i++];
|
28 | } else {
|
29 | _i = _iterator.next();
|
30 | if (_i.done) break;
|
31 | _ref = _i.value;
|
32 | }
|
33 |
|
34 | var i = _ref;
|
35 |
|
36 | if (!filtered.includes(i)) {
|
37 | filtered.push(i);
|
38 | }
|
39 | }
|
40 |
|
41 | return filtered;
|
42 | },
|
43 |
|
44 | |
45 |
|
46 |
|
47 | removeNote: function removeNote(string) {
|
48 | if (!string.includes(' ')) {
|
49 | return string;
|
50 | }
|
51 |
|
52 | return string.split(' ')[0];
|
53 | },
|
54 |
|
55 | |
56 |
|
57 |
|
58 | escapeRegexp: function escapeRegexp(string) {
|
59 | return string.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&');
|
60 | },
|
61 |
|
62 | |
63 |
|
64 |
|
65 | regexp: function regexp(word, escape) {
|
66 | if (escape === void 0) {
|
67 | escape = true;
|
68 | }
|
69 |
|
70 | if (escape) {
|
71 | word = this.escapeRegexp(word);
|
72 | }
|
73 |
|
74 | return new RegExp("(^|[\\s,(])(" + word + "($|[\\s(,]))", 'gi');
|
75 | },
|
76 |
|
77 | |
78 |
|
79 |
|
80 | editList: function editList(value, callback) {
|
81 | var origin = list.comma(value);
|
82 | var changed = callback(origin, []);
|
83 |
|
84 | if (origin === changed) {
|
85 | return value;
|
86 | }
|
87 |
|
88 | var join = value.match(/,\s*/);
|
89 | join = join ? join[0] : ', ';
|
90 | return changed.join(join);
|
91 | },
|
92 |
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | splitSelector: function splitSelector(selector) {
|
102 | return list.comma(selector).map(function (i) {
|
103 | return list.space(i).map(function (k) {
|
104 | return k.split(/(?=\.|#)/g);
|
105 | });
|
106 | });
|
107 | }
|
108 | }; |
\ | No newline at end of file |