Blame view

node_modules/autoprefixer/lib/utils.js 1.33 KB
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  (function() {
    var list;
  
    list = require('postcss/lib/list');
  
    module.exports = {
      error: function(text) {
        var err;
        err = new Error(text);
        err.autoprefixer = true;
        throw err;
      },
      uniq: function(array) {
        var filtered, i, j, len;
        filtered = [];
        for (j = 0, len = array.length; j < len; j++) {
          i = array[j];
          if (filtered.indexOf(i) === -1) {
            filtered.push(i);
          }
        }
        return filtered;
      },
      removeNote: function(string) {
        if (string.indexOf(' ') === -1) {
          return string;
        } else {
          return string.split(' ')[0];
        }
      },
      escapeRegexp: function(string) {
        return string.replace(/[.?*+\^\$\[\]\\(){}|\-]/g, '\\$&');
      },
      regexp: function(word, escape) {
        if (escape == null) {
          escape = true;
        }
        if (escape) {
          word = this.escapeRegexp(word);
        }
        return RegExp("(^|[\\s,(])(" + word + "($|[\\s(,]))", "gi");
      },
      editList: function(value, callback) {
        var changed, join, origin;
        origin = list.comma(value);
        changed = callback(origin, []);
        if (origin === changed) {
          return value;
        } else {
          join = value.match(/,\s*/);
          join = join ? join[0] : ', ';
          return changed.join(join);
        }
      }
    };
  
  }).call(this);