How to use the caniuse-lite.features 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 KaTeX / KaTeX / webpack.common.js View on Github external
options: {plugins: [require('cssnano')()]},
        });
    }

    const lessOptions = {modifyVars: {
        version: `"${version}"`,
    }};

    // use only necessary fonts, overridable by environment variables
    let isCovered = false;
    for (const font of fonts) {
        const override = process.env[`USE_${font.toUpperCase()}`];
        const useFont = override === "true" || override !== "false" && !isCovered;
        lessOptions.modifyVars[`use-${font}`] = useFont;

        const support = caniuse.feature(caniuse.features[font]).stats;
        isCovered = isCovered || useFont && browserslist.every(browser => {
            const [name, version] = browser.split(' ');
            return !support[name] || support[name][version] === 'y';
        });
    }

    return {
        mode: dev ? 'development' : 'production',
        context: __dirname,
        entry: {
            [target.name]: target.entry,
        },
        output: {
            filename: minimize ? '[name].min.js' : '[name].js',
            library: target.library,
            libraryTarget: 'umd',
github JLHwung / postcss-font-family-system-ui / lib / get-system-ui-family.js View on Github external
export default function getSystemUiFamily(supportedBrowsers) {
	const { stats } = caniuse.feature(caniuse.features['font-family-system-ui']);
	const polyfillFlags = generatePolyfillFlags(stats, supportedBrowsers);

	const result = ['system-ui'];
	const polyfill =
		[
			[APPLE_SYSTEM, [
				'-apple-system', // macOS, Safari >= 9.2 < 11, Firefox >= 43
			]],
			[BLINK_MAC_SYSTEM_FONT, [
				'BlinkMacSystemFont', // macOS, Chrome < 56
			]],
			[NO, [
				'Segoe UI', // Windows >= Vista
				'Roboto', // Android >= 4
				'Noto Sans', // Plasma >= 5.5
				'Ubuntu', // Ubuntu >= 10.10
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 anandthakker / doiuse / src / missing-support.js View on Github external
Object.keys(features).forEach(function (feature) {
    const featureData = caniuse.feature(caniuse.features[feature])
    const lackData = filterStats(browsers, featureData.stats)
    const missingData = lackData.missing
    const partialData = lackData.partial
    // browsers with missing or partial support for this feature
    const missing = lackingBrowsers(missingData)
    const partial = lackingBrowsers(partialData)

    if (missing.length > 0 || partial.length > 0) {
      result[feature] = {
        title: featureData.title,
        caniuseData: featureData
      }
      if (missing.length > 0) {
        result[feature].missingData = missingData
        result[feature].missing = missing
      }
github sylvainpolletvillard / postcss-grid-kiss / lib / caniuse.js View on Github external
function caniuse(feature, browsers, accepted = ["y"]) {
	const { stats } = caniuselite.feature(caniuselite.features[feature]);
	return browserslist(browsers)
		.map((browser) => browser.split(" "))
		.every(([browser, version]) => stats[browser] && accepted.includes(stats[browser][version]))
}
github eschirtz / Computer-Science-Series / node_modules / caniuse-api / dist / index.js View on Github external
var _lodash = require("lodash.memoize");

var _lodash2 = _interopRequireDefault(_lodash);

var _browserslist = require("browserslist");

var _browserslist2 = _interopRequireDefault(_browserslist);

var _caniuseLite = require("caniuse-lite");

var _utils = require("./utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var featuresList = Object.keys(_caniuseLite.features);

var browsers = void 0;
function setBrowserScope(browserList) {
  browsers = (0, _utils.cleanBrowsersList)(browserList);
}

function getBrowserScope() {
  return browsers;
}

var parse = (0, _lodash2.default)(_utils.parseCaniuseData, function (feat, browsers) {
  return feat.title + browsers;
});

function getSupport(query) {
  var feature = void 0;
github eschirtz / Computer-Science-Series / node_modules / caniuse-api / dist / index.js View on Github external
function getSupport(query) {
  var feature = void 0;
  try {
    feature = (0, _caniuseLite.feature)(_caniuseLite.features[query]);
  } catch (e) {
    var res = find(query);
    if (res.length === 1) return getSupport(res[0]);
    throw new ReferenceError("Please provide a proper feature name. Cannot find " + query);
  }
  return parse(feature, browsers);
}

caniuse-lite

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

CC-BY-4.0
Latest version published 3 days ago

Package Health Score

89 / 100
Full package analysis