source: trip-planner-front/node_modules/caniuse-api/dist/utils.js@ 1ad8e64

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

initial commit

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.contains = contains;
7exports.parseCaniuseData = parseCaniuseData;
8exports.cleanBrowsersList = cleanBrowsersList;
9
10var _lodash = require("lodash.uniq");
11
12var _lodash2 = _interopRequireDefault(_lodash);
13
14var _browserslist = require("browserslist");
15
16var _browserslist2 = _interopRequireDefault(_browserslist);
17
18function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
20function contains(str, substr) {
21 return !!~str.indexOf(substr);
22}
23
24function parseCaniuseData(feature, browsers) {
25 var support = {};
26 var letters;
27 var letter;
28
29 browsers.forEach(function (browser) {
30 support[browser] = {};
31 for (var info in feature.stats[browser]) {
32 letters = feature.stats[browser][info].replace(/#\d+/, "").trim().split(" ");
33 info = parseFloat(info.split("-")[0]); //if info is a range, take the left
34 if (isNaN(info)) continue;
35 for (var i = 0; i < letters.length; i++) {
36 letter = letters[i];
37 if (letter === "d") {
38 // skip this letter, we don't support it yet
39 continue;
40 } else if (letter === "y") {
41 // min support asked, need to find the min value
42 if (typeof support[browser][letter] === "undefined" || info < support[browser][letter]) {
43 support[browser][letter] = info;
44 }
45 } else {
46 // any other support, need to find the max value
47 if (typeof support[browser][letter] === "undefined" || info > support[browser][letter]) {
48 support[browser][letter] = info;
49 }
50 }
51 }
52 }
53 });
54
55 return support;
56}
57
58function cleanBrowsersList(browserList) {
59 return (0, _lodash2.default)((0, _browserslist2.default)(browserList).map(function (browser) {
60 return browser.split(" ")[0];
61 }));
62}
Note: See TracBrowser for help on using the repository browser.