Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isFeatureSupported(featureId: string): boolean {
// y: feature is fully available
// n: feature is unavailable
// a: feature is partially supported
// x: feature is prefixed
const criteria = [
'y',
'a',
];
const data = feature(features[featureId]);
return !this._supportedBrowsers
.some(browser => {
const [agentId, version] = browser.split(' ');
const browserData = data.stats[agentId];
const featureStatus = (browserData && browserData[version]) as string | undefined;
// We are only interested in the first character
// Ex: when 'a #4 #5', we only need to check for 'a'
// as for such cases we should polyfill these features as needed
return !featureStatus || !criteria.includes(featureStatus.charAt(0));
});
}
}
function getUnsupportedBrowsersByFeature(feature) {
const caniuseFeature = caniuse.features[feature]; // if feature support can be determined
if (caniuseFeature) {
const stats = caniuse.feature(caniuseFeature).stats; // return an array of browsers and versions that do not support the feature
const results = Object.keys(stats).reduce((browsers, browser) => browsers.concat(Object.keys(stats[browser]).filter(version => stats[browser][version].indexOf('y') !== 0).map(version => `${browser} ${version}`)), []);
return results;
} else {
// otherwise, return that the feature does not work in any browser
return ['> 0%'];
}
}
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Browsers = require('./browsers');
var brackets = require('./brackets');
var Value = require('./value');
var utils = require('./utils');
var postcss = require('postcss');
var supported = [];
var data = require('caniuse-lite').feature(require('caniuse-lite/data/features/css-featurequeries.js'));
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
if (/y/.test(support)) {
supported.push(browser + ' ' + version);
}
}
}
var Supports = function () {
function Supports(Prefixes, all) {
_classCallCheck(this, Supports);
this.Prefixes = Prefixes;
this.all = all;
function f(data, opts, callback) {
data = unpack(data);
if (!callback) {
var _ref = [opts, {}];
callback = _ref[0];
opts = _ref[1];
}
var match = opts.match || /\sx($|\s)/;
var need = [];
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
"use strict";
var postcss = require('postcss');
var data = require('caniuse-lite').feature(require('caniuse-lite/data/features/css-featurequeries.js'));
var Browsers = require('./browsers');
var brackets = require('./brackets');
var Value = require('./value');
var utils = require('./utils');
var supported = [];
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
function f(data, opts, callback) {
data = unpack(data);
if (!callback) {
var _ref = [opts, {}];
callback = _ref[0];
opts = _ref[1];
}
var match = opts.match || /\sx($|\s)/;
var need = [];
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
if (support.match(match)) {
need.push(browser + ' ' + version);
function f(data, opts, callback) {
data = unpack(data);
if (!callback) {
var _ref = [opts, {}];
callback = _ref[0];
opts = _ref[1];
}
var match = opts.match || /\sx($|\s)/;
var need = [];
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
if (support.match(match)) {
need.push(browser + ' ' + version);
function f(data, opts, callback) {
data = unpack(data);
if (!callback) {
var _ref = [opts, {}];
callback = _ref[0];
opts = _ref[1];
}
var match = opts.match || /\sx($|\s)/;
var need = [];
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];
if (support.match(match)) {
need.push(browser + ' ' + version);
"use strict";
var postcss = require('postcss');
var data = require('caniuse-lite').feature(require('caniuse-lite/data/features/css-featurequeries.js'));
var Browsers = require('./browsers');
var brackets = require('./brackets');
var Value = require('./value');
var utils = require('./utils');
var supported = [];
for (var browser in data.stats) {
var versions = data.stats[browser];
for (var version in versions) {
var support = versions[version];