How to use caniuse-db - 10 common examples

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 GoogleChromeLabs / pptraas.com / helpers / gsearch.js View on Github external
*
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author ebidel@ (Eric Bidelman)
 */

// Adapted from https://github.com/GoogleChromeLabs/puppeteer-examples/blob/master/google_search_features.js.

/* global document */

const fs = require('fs');
const caniuseDB = require('caniuse-db/data.json').data;

const GOOGLE_SEARCH_CHROME_VERSION = process.env.CHROME_VERSION || 41;

/* eslint-disable quote-props */
const BlinkFeatureNameToCaniuseName = {
  AddEventListenerPassiveTrue: 'passive-event-listener',
  AddEventListenerPassiveFalse: 'passive-event-listener',
  PromiseConstructor: 'promises',
  PromiseResolve: 'promises',
  PromiseReject: 'promises',
  V8PromiseChain: 'promises',
  DocumentRegisterElement: 'custom-elements',
  V0CustomElementsRegisterHTMLCustomTag: 'custom-elements',
  V0CustomElementsCreateCustomTagElement: 'custom-elements',
  V0CustomElementsRegisterHTMLTypeExtension: 'custom-elements',
  V0CustomElementsCreateTypeExtensionElement: 'custom-elements',
github mozilla-frontend-infra / firefox-health-dashboard / src / status / caniuse.js View on Github external
result[platform].version = version;
            }
            return false;
          }),
        )(versions);
      });
      const firefoxRef = find({ caniuse_ref: ref })(firefoxStatus);
      if (firefoxRef) {
        result.firefox.ref = firefoxRef.slug;
      }
      return result;
    }),
    map(scoreFeature),
    filter(({ completeness }) => completeness < 4 && completeness >= 0.5),
    // filter(({ recency }) => recency >= 0.5)
  )(caniuse.data);
}
github dmnsgn / sublime-stylefmt / node_modules / doiuse / lib / missing-support.js View on Github external
Object.keys(features).forEach(function (feature) {
    var featureData = caniuse.data[feature];
    var lackData = filterStats(browsers, featureData.stats);
    var missingData = lackData.missing;
    var partialData = lackData.partial;
    // browsers with missing or partial support for this feature
    var missing = lackingBrowsers(missingData);
    var 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 jonrohan / browserl.ist / routes / index.js View on Github external
"use strict";

const express = require("express");
const router = express.Router();
const browserslist = require("browserslist");
const bv = require("browserslist/package.json").version;
const cv = require("caniuse-db/package.json").version;
const caniuse = require("caniuse-db/data.json").agents;
const GA_ID = process.env.GA_ID;

let caniuseRegion;

function getCoverage(data, version) {
  const lastVersion = Object.keys(data).sort((a, b) => {
    return parseInt(b) - parseInt(a);
  })[0];
  // If specific version coverage is missing, fall back to "version zero"
  return data[version] !== undefined ? data[version] : data[lastVersion];
}

function getRegionCoverage(region, id, version) {
  if (!caniuseRegion) {
    caniuseRegion = require(`caniuse-db/region-usage-json/${region}.json`);
github mozilla-frontend-infra / firefox-health-dashboard / src / status / chrome.js View on Github external
if (firefoxRef.firefox_version) {
          result.firefox.version = firefoxRef.firefox_version;
        }
      } else if (/show_bug\.cgi/.test((ff && ff.view.url) || '')) {
        const id = ff.view.url.match(/id=([^$#]+)/)[1];
        queuedIds.push({
          id: id,
          feature: result,
        });
      }
      let caniuseRef = findKey({ chrome_id: chromestatus.id })(caniuse.data);
      if (!caniuseRef && firefoxRef && firefoxRef.caniuse_ref) {
        caniuseRef = firefoxRef.caniuse_ref;
      }
      if (caniuseRef) {
        const ref = caniuse.data[caniuseRef];
        result.caniuse = {
          ref: caniuseRef,
          usage: ref.usage_perc_y + ref.usage_perc_a,
        };
      }
      return result;
    }),
  )(chromeStatus);
github mozilla-frontend-infra / firefox-health-dashboard / src / status / chrome.js View on Github external
result.name = firefoxRef.title;
        result.firefox.ref = firefoxRef.slug;
        result.firefox.status = resolveStatus(firefoxRef.firefox_status);
        result.safari.status = resolveStatus(firefoxRef.webkit_status);
        result.ie.status = resolveStatus(firefoxRef.ie_status);
        if (firefoxRef.firefox_version) {
          result.firefox.version = firefoxRef.firefox_version;
        }
      } else if (/show_bug\.cgi/.test((ff && ff.view.url) || '')) {
        const id = ff.view.url.match(/id=([^$#]+)/)[1];
        queuedIds.push({
          id: id,
          feature: result,
        });
      }
      let caniuseRef = findKey({ chrome_id: chromestatus.id })(caniuse.data);
      if (!caniuseRef && firefoxRef && firefoxRef.caniuse_ref) {
        caniuseRef = firefoxRef.caniuse_ref;
      }
      if (caniuseRef) {
        const ref = caniuse.data[caniuseRef];
        result.caniuse = {
          ref: caniuseRef,
          usage: ref.usage_perc_y + ref.usage_perc_a,
        };
      }
      return result;
    }),
  )(chromeStatus);
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 getBrowsers = function () {
  return caniuse.agents;
};
github anandthakker / doiuse / dist / lib / util.js View on Github external
'use strict'

var agents = require('caniuse-db/data').agents

module.exports = {
  formatBrowserName: function formatBrowserName (browserKey, versions) {
    var browserName = (agents[browserKey] || {}).browser
    if (!versions) {
      return browserName
    }
    return browserName + ' (' + versions.join(',') + ')'
  }
}