.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / autoprefixer / lib / utils.js
1 'use strict';
2
3 var list = require('postcss').list;
4
5 module.exports = {
6
7     /**
8      * Throw special error, to tell beniary,
9      * that this error is from Autoprefixer.
10      */
11     error: function error(text) {
12         var err = new Error(text);
13         err.autoprefixer = true;
14         throw err;
15     },
16
17
18     /**
19      * Return array, that doesn’t contain duplicates.
20      */
21     uniq: function uniq(array) {
22         var filtered = [];
23         for (var _iterator = array, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
24             var _ref;
25
26             if (_isArray) {
27                 if (_i >= _iterator.length) break;
28                 _ref = _iterator[_i++];
29             } else {
30                 _i = _iterator.next();
31                 if (_i.done) break;
32                 _ref = _i.value;
33             }
34
35             var i = _ref;
36
37             if (filtered.indexOf(i) === -1) {
38                 filtered.push(i);
39             }
40         }
41         return filtered;
42     },
43
44
45     /**
46      * Return "-webkit-" on "-webkit- old"
47      */
48     removeNote: function removeNote(string) {
49         if (string.indexOf(' ') === -1) {
50             return string;
51         }
52
53         return string.split(' ')[0];
54     },
55
56
57     /**
58      * Escape RegExp symbols
59      */
60     escapeRegexp: function escapeRegexp(string) {
61         return string.replace(/[.?*+\^\$\[\]\\(){}|\-]/g, '\\$&');
62     },
63
64
65     /**
66      * Return regexp to check, that CSS string contain word
67      */
68     regexp: function regexp(word) {
69         var escape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
70
71         if (escape) {
72             word = this.escapeRegexp(word);
73         }
74         return new RegExp('(^|[\\s,(])(' + word + '($|[\\s(,]))', 'gi');
75     },
76
77
78     /**
79      * Change comma list
80      */
81     editList: function editList(value, callback) {
82         var origin = list.comma(value);
83         var changed = callback(origin, []);
84
85         if (origin === changed) {
86             return value;
87         }
88
89         var join = value.match(/,\s*/);
90         join = join ? join[0] : ', ';
91         return changed.join(join);
92     }
93 };