How to use the caniuse-lite.feature function in caniuse-lite

To help you get started, we’ve selected a few caniuse-lite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular-cli / packages / angular_devkit / build_angular / src / utils / build-browser-features.ts View on Github external
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));
      });
  }
}
github lintopher0315 / Quick-Math / node_modules / postcss-preset-env / index.cjs.js View on Github external
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%'];
  }
}
github Graphite-Docs / graphite / node_modules / autoprefixer / lib / supports.js View on Github external
'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;
github sindresorhus / sublime-autoprefixer / node_modules / autoprefixer / data / prefixes.js View on Github external
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];
github GoogleContainerTools / kpt / site / node_modules / autoprefixer / lib / supports.js View on Github external
"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];
github fga-eps-mds / 2018.2-Kalkuli / website / node_modules / autoprefixer / data / prefixes.js View on Github external
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);
github sean-codes / microprojects / node_modules / autoprefixer / data / prefixes.js View on Github external
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);
github cytle / wechat_web_devtools / package.nw / node_modules / autoprefixer / data / prefixes.js View on Github external
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);
github sindresorhus / sublime-autoprefixer / node_modules / autoprefixer / lib / supports.js View on Github external
"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];

caniuse-lite

A smaller version of caniuse-db, with only the essentials!

CC-BY-4.0
Latest version published 1 day ago

Package Health Score

89 / 100
Full package analysis