Blame view

node_modules/autoprefixer/lib/browsers.js 2.28 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  (function() {
    var Browsers, browserslist, utils;
  
    browserslist = require('browserslist');
  
    utils = require('./utils');
  
    Browsers = (function() {
      Browsers.prefixes = function() {
        var data, i, name;
        if (this.prefixesCache) {
          return this.prefixesCache;
        }
        data = require('caniuse-db/data.json').agents;
        return this.prefixesCache = utils.uniq((function() {
          var results;
          results = [];
          for (name in data) {
            i = data[name];
            results.push("-" + i.prefix + "-");
          }
          return results;
        })()).sort(function(a, b) {
          return b.length - a.length;
        });
      };
  
      Browsers.withPrefix = function(value) {
        if (!this.prefixesRegexp) {
          this.prefixesRegexp = RegExp("" + (this.prefixes().join('|')));
        }
        return this.prefixesRegexp.test(value);
      };
  
      function Browsers(data1, requirements, options, stats) {
        this.data = data1;
        this.options = options;
        this.stats = stats;
        this.selected = this.parse(requirements);
      }
  
      Browsers.prototype.parse = function(requirements) {
        var ref, ref1;
        return browserslist(requirements, {
          stats: this.stats,
          path: (ref = this.options) != null ? ref.from : void 0,
          env: (ref1 = this.options) != null ? ref1.env : void 0
        });
      };
  
      Browsers.prototype.browsers = function(criteria) {
        var browser, data, ref, selected, versions;
        selected = [];
        ref = this.data;
        for (browser in ref) {
          data = ref[browser];
          versions = criteria(data).map(function(version) {
            return browser + " " + version;
          });
          selected = selected.concat(versions);
        }
        return selected;
      };
  
      Browsers.prototype.prefix = function(browser) {
        var data, name, prefix, ref, version;
        ref = browser.split(' '), name = ref[0], version = ref[1];
        data = this.data[name];
        if (data.prefix_exceptions) {
          prefix = data.prefix_exceptions[version];
        }
        prefix || (prefix = data.prefix);
        return '-' + prefix + '-';
      };
  
      Browsers.prototype.isSelected = function(browser) {
        return this.selected.indexOf(browser) !== -1;
      };
  
      return Browsers;
  
    })();
  
    module.exports = Browsers;
  
  }).call(this);