How to use the caniuse-db/data.data function in caniuse-db

To help you get started, we’ve selected a few caniuse-db 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 caniuse-js / caniuse-js / lib / caniuse.js View on Github external
var getKeywords = function () {
  var keywords = [];
  _.each(caniuse.data, function (item) {
    if (item.keywords === '') { return; }
    keywords = keywords.concat(item.keywords.split(','));
  });
  return keywords;
};
github caniuse-js / caniuse-js / lib / caniuse.js View on Github external
var query = function (keyword, browser, version) {
  if (_.isUndefined(caniuse.agents[browser])) {
    logger.warn('Skipping ' + browser, '- It is not a recognized browser');
    return null;
  } else if (!_.contains(caniuse.agents[browser].versions, version)) {
    logger.warn('Skipping ' + browser, version, '- It is not a recognized version');
    return null;
  }

  var propertyData = _.find(caniuse.data, function (item) {
    return item.keywords.indexOf(keyword) !== -1;
  });
  return propertyData ? propertyData.stats[browser][version] : null;
};