mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 03:17:30 -04:00
44 lines
2.3 KiB
JavaScript
44 lines
2.3 KiB
JavaScript
|
// Generated by CoffeeScript 2.0.0-beta8
|
||
|
'use strict';
|
||
|
|
||
|
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
|
||
|
|
||
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||
|
|
||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
||
|
|
||
|
var browserslist = require('browserslist');
|
||
|
var _ = require('lodash');
|
||
|
module.exports = (function () {
|
||
|
function BrowserSelection(query) {
|
||
|
_classCallCheck(this, BrowserSelection);
|
||
|
|
||
|
this.browsersRequest = query;
|
||
|
this._list = browserslist(this.browsersRequest).map(function (s) {
|
||
|
return s.split(' ');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
_createClass(BrowserSelection, [{
|
||
|
key: 'test',
|
||
|
value: function test(browser, version) {
|
||
|
version = version.split('-');
|
||
|
if (version.length === 1) version.push(version[0]);
|
||
|
return _.find(this._list, function (_ref) {
|
||
|
var _ref2 = _slicedToArray(_ref, 2);
|
||
|
|
||
|
var b = _ref2[0];
|
||
|
var v = _ref2[1];
|
||
|
|
||
|
return b === browser && v >= version[0] && v <= version[1];
|
||
|
});
|
||
|
}
|
||
|
}, {
|
||
|
key: 'list',
|
||
|
value: function list() {
|
||
|
return this._list.slice();
|
||
|
}
|
||
|
}]);
|
||
|
|
||
|
return BrowserSelection;
|
||
|
})();
|