How to use the browserslist.versionAliases function in browserslist

To help you get started, we’ve selected a few browserslist 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 open-wc / open-wc / packages / es-dev-server / src / utils / user-agent-compat.js View on Github external
function normalizeSamsungVersion(browser, version) {
  try {
    browserslist(`${browser} ${version}`);
    // browserslist didn't throw, return the valid version
    return version;
  } catch (error) {
    // we gave an invalid version to browserslist, so we try to
    // find the nearest matching major version for samsung browser
    const validVersions = [
      ...Object.keys(browserslist.versionAliases.samsung),
      ...browserslist.data.samsung.versions,
    ];

    return validVersions.find(validVersion => validVersion[0] === version[0]);
  }
}
github Nyalab / caniuse-api / test / index.js View on Github external
test("isSupported test with browsers caniuse doesn't know", (t) => {
  browserslist.data.notabrowser = {
    name: 'notabrowser',
    versions: ['1'],
    released: ['1']
  };
  browserslist.versionAliases.notabrowser = {}

  t.notOk(caniuse.isSupported("border-radius", "notabrowser 1"), "do not throw on non existing data")

  delete browserslist.data.notabrowser
  delete browserslist.versionAliases.notabrowser
  t.end()
})
github Nyalab / caniuse-api / test / index.js View on Github external
test("isSupported test with browsers caniuse doesn't know", (t) => {
  browserslist.data.notabrowser = {
    name: 'notabrowser',
    versions: ['1'],
    released: ['1']
  };
  browserslist.versionAliases.notabrowser = {}

  t.notOk(caniuse.isSupported("border-radius", "notabrowser 1"), "do not throw on non existing data")

  delete browserslist.data.notabrowser
  delete browserslist.versionAliases.notabrowser
  t.end()
})