source: trip-planner-front/node_modules/autoprefixer/lib/browsers.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1"use strict";
2
3var browserslist = require('browserslist');
4
5var agents = require('caniuse-lite').agents;
6
7var utils = require('./utils');
8
9var Browsers = /*#__PURE__*/function () {
10 /**
11 * Return all prefixes for default browser data
12 */
13 Browsers.prefixes = function prefixes() {
14 if (this.prefixesCache) {
15 return this.prefixesCache;
16 }
17
18 this.prefixesCache = [];
19
20 for (var name in agents) {
21 this.prefixesCache.push("-" + agents[name].prefix + "-");
22 }
23
24 this.prefixesCache = utils.uniq(this.prefixesCache).sort(function (a, b) {
25 return b.length - a.length;
26 });
27 return this.prefixesCache;
28 }
29 /**
30 * Check is value contain any possible prefix
31 */
32 ;
33
34 Browsers.withPrefix = function withPrefix(value) {
35 if (!this.prefixesRegexp) {
36 this.prefixesRegexp = new RegExp(this.prefixes().join('|'));
37 }
38
39 return this.prefixesRegexp.test(value);
40 };
41
42 function Browsers(data, requirements, options, browserslistOpts) {
43 this.data = data;
44 this.options = options || {};
45 this.browserslistOpts = browserslistOpts || {};
46 this.selected = this.parse(requirements);
47 }
48 /**
49 * Return browsers selected by requirements
50 */
51
52
53 var _proto = Browsers.prototype;
54
55 _proto.parse = function parse(requirements) {
56 var opts = {};
57
58 for (var i in this.browserslistOpts) {
59 opts[i] = this.browserslistOpts[i];
60 }
61
62 opts.path = this.options.from;
63 return browserslist(requirements, opts);
64 }
65 /**
66 * Return prefix for selected browser
67 */
68 ;
69
70 _proto.prefix = function prefix(browser) {
71 var _browser$split = browser.split(' '),
72 name = _browser$split[0],
73 version = _browser$split[1];
74
75 var data = this.data[name];
76 var prefix = data.prefix_exceptions && data.prefix_exceptions[version];
77
78 if (!prefix) {
79 prefix = data.prefix;
80 }
81
82 return "-" + prefix + "-";
83 }
84 /**
85 * Is browser is selected by requirements
86 */
87 ;
88
89 _proto.isSelected = function isSelected(browser) {
90 return this.selected.includes(browser);
91 };
92
93 return Browsers;
94}();
95
96module.exports = Browsers;
Note: See TracBrowser for help on using the repository browser.