How to use the browserslist.coverage 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 postcss / autoprefixer / test / info.js View on Github external
it('doesn\'t show transitions unless they are necessary', () => {
        const browsers = new Browsers(data.browsers,
            ['chrome 30', 'firefox 20', 'ie 6']);
        const prefixes = new Prefixes(data.prefixes, browsers);

        const coverage = browserslist.coverage(
            ['chrome 30', 'firefox 20', 'ie 6']);
        const round    = Math.round(coverage * 100) / 100.0;

        info(prefixes).should.eql(
            'Browsers:\n' +
            '  Chrome: 30\n' +
            '  Firefox: 20\n' +
            '  IE: 6\n' +
            '\n' +
            `These browsers account for ${ round }% ` +
            'of all users globally\n' +
            '\n' +
            'Properties:\n' +
            '  a: webkit, moz\n' +
            '\n' +
            'Values:\n' +
github KidkArolis / jetpack / lib / browsers.js View on Github external
function browsers (options) {
  if (options.target.modern) {
    const modern = query({ modern: true })
    const modernBrowsers = browserslist(modern)
    console.log(chalk.yellow('[modern query]'))
    console.log((Array.isArray(modern) ? modern : modern.split(', ')).join('\n'))
    console.log('')
    console.log(chalk.yellow('[modern browsers]'))
    console.log(modernBrowsers.join('\n'))
    console.log('')
    console.log(chalk.yellow(`[modern coverage ${options.coverage || 'globally'}]`))
    console.log(browserslist.coverage(modernBrowsers, options.coverage || undefined).toFixed(2) + '%')
    console.log('')
  }

  if (options.target.legacy) {
    const legacy = query({ modern: false }) || browserslist.defaults
    const legacyBrowsers = browserslist(legacy)
    console.log(chalk.yellow('[legacy query]'))
    console.log((Array.isArray(legacy) ? legacy : legacy.split(', ')).join('\n'))
    console.log('')
    console.log(chalk.yellow('[legacy browsers]'))
    console.log(legacyBrowsers.join('\n'))
    console.log('')
    console.log(chalk.yellow(`[legacy coverage ${options.coverage || 'globally'}]`))
    console.log(browserslist.coverage(legacyBrowsers, options.coverage || undefined).toFixed(2) + '%')
    console.log('')
  }
github KidkArolis / jetpack / lib / browsers.js View on Github external
console.log(chalk.yellow(`[modern coverage ${options.coverage || 'globally'}]`))
    console.log(browserslist.coverage(modernBrowsers, options.coverage || undefined).toFixed(2) + '%')
    console.log('')
  }

  if (options.target.legacy) {
    const legacy = query({ modern: false }) || browserslist.defaults
    const legacyBrowsers = browserslist(legacy)
    console.log(chalk.yellow('[legacy query]'))
    console.log((Array.isArray(legacy) ? legacy : legacy.split(', ')).join('\n'))
    console.log('')
    console.log(chalk.yellow('[legacy browsers]'))
    console.log(legacyBrowsers.join('\n'))
    console.log('')
    console.log(chalk.yellow(`[legacy coverage ${options.coverage || 'globally'}]`))
    console.log(browserslist.coverage(legacyBrowsers, options.coverage || undefined).toFixed(2) + '%')
    console.log('')
  }
}
github pvdlg / uprogress / build / browserslist.js View on Github external
}

			return acc;
		}, {});
	const browsers = supportedBrowsers
		.map(browser => browser.split(' '))
		.reduce((acc, val) => {
			if (val[0] in acc) {
				acc[val[0]].unshift(val[1]);
			} else {
				acc[val[0]] = [val[1]];
			}

			return acc;
		}, {});
	const result = {coverage: browserslist.coverage(supportedBrowsers), browsers: {}};

	for (let i = 0, keys = Object.keys(BROWSERS_LABELS), {length} = keys; i < length; i++) {
		if (keys[i] in browsers) {
			result.browsers[BROWSERS_LABELS[keys[i]].label] = {
				versions: browsers[keys[i]],
				oldest: browsers[keys[i]][0],
				tested: sauceLabsBrowsers[BROWSERS_LABELS[keys[i]].saucelabs],
			};
		}
	}

	process.stdout.write(JSON.stringify(result));
});
github johandb / svg-drawing-tool / node_modules / autoprefixer / lib / info.js View on Github external
} else {
      versions[_name2] = [version];
    }
  }

  var out = 'Browsers:\n';

  for (var browser in versions) {
    var list = versions[browser];
    list = list.sort(function (a, b) {
      return parseFloat(b) - parseFloat(a);
    });
    out += "  " + browser + ": " + list.join(', ') + "\n";
  }

  var coverage = browserslist.coverage(prefixes.browsers.selected);
  var round = Math.round(coverage * 100) / 100.0;
  out += "\nThese browsers account for " + round + "% of all users globally\n";
  var atrules = [];

  for (var name in prefixes.add) {
    var data = prefixes.add[name];

    if (name[0] === '@' && data.prefixes) {
      atrules.push(prefix(name, data.prefixes));
    }
  }

  if (atrules.length > 0) {
    out += "\nAt-Rules:\n" + atrules.sort().join('');
  }
github sindresorhus / sublime-autoprefixer / node_modules / autoprefixer / lib / info.js View on Github external
} else {
      versions[_name2] = [version];
    }
  }

  var out = 'Browsers:\n';

  for (var browser in versions) {
    var list = versions[browser];
    list = list.sort(function (a, b) {
      return parseFloat(b) - parseFloat(a);
    });
    out += "  " + browser + ": " + list.join(', ') + "\n";
  }

  var coverage = browserslist.coverage(prefixes.browsers.selected);
  var round = Math.round(coverage * 100) / 100.0;
  out += "\nThese browsers account for " + round + "% of all users globally\n";
  var atrules = [];

  for (var name in prefixes.add) {
    var data = prefixes.add[name];

    if (name[0] === '@' && data.prefixes) {
      atrules.push(prefix(name, data.prefixes));
    }
  }

  if (atrules.length > 0) {
    out += "\nAt-Rules:\n" + atrules.sort().join('');
  }
github makuga01 / dnsFookup / FE / node_modules / autoprefixer / lib / info.js View on Github external
} else {
      versions[_name2] = [version];
    }
  }

  var out = 'Browsers:\n';

  for (var browser in versions) {
    var list = versions[browser];
    list = list.sort(function (a, b) {
      return parseFloat(b) - parseFloat(a);
    });
    out += "  " + browser + ": " + list.join(', ') + "\n";
  }

  var coverage = browserslist.coverage(prefixes.browsers.selected);
  var round = Math.round(coverage * 100) / 100.0;
  out += "\nThese browsers account for " + round + "% of all users globally\n";
  var atrules = [];

  for (var name in prefixes.add) {
    var data = prefixes.add[name];

    if (name[0] === '@' && data.prefixes) {
      atrules.push(prefix(name, data.prefixes));
    }
  }

  if (atrules.length > 0) {
    out += "\nAt-Rules:\n" + atrules.sort().join('');
  }
github jonrohan / browserl.ist / routes / index.js View on Github external
version,
        id,
        name,
        coverage,
        logo: `/images/${id}.png`
      });
    });
  }

  res.render("index", {
    compatible,
    query,
    GA_ID,
    bv,
    cv,
    coverage: browserslist.coverage(bl, region),
    description:
      "A page to display compatible browsers from a browserslist string.",
    region: region || "Global"
  });
});
github daviddbarrero / Ionic-4-firebase / node_modules / autoprefixer / lib / info.js View on Github external
versions[name].push(version);
        } else {
            versions[name] = [version];
        }
    }

    var out = 'Browsers:\n';
    for (var _browser in versions) {
        var list = versions[_browser];
        list = list.sort(function (a, b) {
            return parseFloat(b) - parseFloat(a);
        });
        out += '  ' + _browser + ': ' + list.join(', ') + '\n';
    }

    var coverage = browserslist.coverage(prefixes.browsers.selected);
    var round = Math.round(coverage * 100) / 100.0;
    out += '\nThese browsers account for ' + round + '% of all users globally\n';

    var atrules = '';
    for (var name in prefixes.add) {
        var data = prefixes.add[name];
        if (name[0] === '@' && data.prefixes) {
            atrules += prefix(name, data.prefixes);
        }
    }
    if (atrules !== '') {
        out += '\nAt-Rules:\n' + atrules;
    }

    var selectors = '';
    for (var _iterator2 = prefixes.add.selectors, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
github aermin / ghChat / node_modules / autoprefixer / lib / info.js View on Github external
versions[name].push(version);
        } else {
            versions[name] = [version];
        }
    }

    var out = 'Browsers:\n';
    for (var _browser in versions) {
        var list = versions[_browser];
        list = list.sort(function (a, b) {
            return parseFloat(b) - parseFloat(a);
        });
        out += '  ' + _browser + ': ' + list.join(', ') + '\n';
    }

    var coverage = browserslist.coverage(prefixes.browsers.selected);
    var round = Math.round(coverage * 100) / 100.0;
    out += '\nThese browsers account for ' + round + '% of all users globally\n';

    var atrules = '';
    for (var name in prefixes.add) {
        var data = prefixes.add[name];
        if (name[0] === '@' && data.prefixes) {
            atrules += prefix(name, data.prefixes);
        }
    }
    if (atrules !== '') {
        out += '\nAt-Rules:\n' + atrules;
    }

    var selectors = '';
    for (var _iterator2 = prefixes.add.selectors, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {