Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browserslist

Package Overview
Dependencies
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserslist - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 1.2
* Add `browserslist.coverage()` method.
* Add `--coverage` and `-c` argument to CLI.
* Add `-v` argument support to CLI.
* Better error handling in CLI.
## 1.1.3

@@ -2,0 +8,0 @@ * Fix jspm support (by Sean Anderson).

54

cli.js

@@ -11,2 +11,19 @@ #!/usr/bin/env node

function error(msg) {
process.stderr.write(pkg.name + ': ' + msg + '\n');
process.exit(1);
}
function query(queries) {
try {
return browserslist(queries);
} catch (e) {
if ( e.name === 'BrowserslistError' ) {
return error(e.message);
} else {
throw e;
}
}
}
if ( args.length === 0 || isArg('--help') || isArg('-h') ) {

@@ -16,21 +33,30 @@ process.stdout.write([

'',
'Usage: ' + pkg.name + ' "QUERIES"'
'Usage:',
' ' + pkg.name + ' "QUERIES"',
' ' + pkg.name + ' --coverage "QUERIES"'
].join('\n') + '\n');
} else if ( isArg('--version') ) {
} else if ( isArg('--version') || isArg('-v') ) {
process.stdout.write(pkg.name + ' ' + pkg.version + '\n');
} else if ( isArg('--version') || isArg('-v') ) {
process.stdout.write(pkg.name + ' ' + pkg.version + '\n');
} else if ( isArg('--coverage') || isArg('-c') ) {
var browsers = args.find(function (i) {
return i[0] !== '-';
});
if ( !browsers ) error('Define a browsers query to get coverage');
var result = browserslist.coverage(query(browsers));
var round = Math.round(result * 100) / 100.0;
process.stdout.write(
'These browsers account for ' + round + '% of all users globally\n');
} else if ( args.length === 1 && args[0][0] !== '-' ) {
query(args[0]).forEach(function (browser) {
process.stdout.write(browser + '\n');
});
} else {
try {
browserslist(args[0]).forEach(function (browser) {
process.stdout.write(browser + '\n');
});
} catch (e) {
if ( e.name === 'BrowserslistError' ) {
process.stderr.write(pkg.name + ': ' + e.message + '\n');
process.exit(1);
} else {
throw e;
}
}
error('Unknown arguments. Use --help to pick right one.');
}

@@ -149,4 +149,3 @@ var caniuse = require('caniuse-db/data.json').agents;

} else {
var alias = browserslist.versionAliases[data.name][version];
if ( alias ) return alias;
return browserslist.versionAliases[data.name][version];
}

@@ -226,2 +225,9 @@ };

// Return browsers market coverage
browserslist.coverage = function (browsers) {
return browsers.reduce(function (all, i) {
return all + browserslist.usage.global[i];
}, 0);
};
// Return array of queries from config content

@@ -228,0 +234,0 @@ browserslist.parseConfig = function (string) {

{
"name": "browserslist",
"version": "1.1.3",
"version": "1.2.0",
"description": "Get browsers versions that matches given criterias like in Autoprefixer",

@@ -16,9 +16,9 @@ "keywords": [

"dependencies": {
"caniuse-db": "^1.0.30000409"
"caniuse-db": "^1.0.30000430"
},
"bin": "./cli.js",
"devDependencies": {
"eslint-config-postcss": "1.0.0",
"eslint": "1.10.3",
"ava": "0.11.0"
"eslint-config-postcss": "2.0.2",
"eslint": "2.4.0",
"ava": "0.13.0"
},

@@ -25,0 +25,0 @@ "scripts": {

@@ -13,4 +13,4 @@ # Browserslist [![Build Status][ci-img]][ci]

browserslist('last 1 version, > 10%');
//=> ["and_chr 47", "chrome 48", "chrome 47", "edge 13", "firefox 44",
// "ie 11", "ie_mob 11", "ios_saf 9.0-9.2", "opera 34", "safari 9"]
//=> ["and_chr 49", "chrome 49", "chrome 48", "edge 13", "firefox 45",
// "ie 11", "ie_mob 11", "ios_saf 9.0-9.2", "opera 35", "safari 9"]
```

@@ -204,1 +204,16 @@

```
## Coverage
You can get total users coverage for selected browsers by JS API:
```js
browserslist.coverage(browserslist('> 1%')) //=> 81.4
```
Or by CLI:
```sh
$ browserslist --coverage "> 1%"
These browsers account for 81.4% of all users globally
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc