Socket
Socket
Sign inDemoInstall

browserslist

Package Overview
Dependencies
Maintainers
1
Versions
191
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 0.5.0 to 1.0.0

cli.js

6

CHANGELOG.md

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

## 1.0.0
* Remove Opera 12.1 from default query.
* Add Microsoft Edge support (by Andrey Polischuk).
* Add CLI for debug and non-JS usage (by Luke Horvat).
* Use own class in Browserslist errors.
## 0.5

@@ -2,0 +8,0 @@ * Add version ranges `IE 6-9` (by Ben Briggs).

73

index.js

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

var uniq = function (array) {
function uniq(array) {
var filtered = [];

@@ -12,4 +12,19 @@ for ( var i = 0; i < array.length; i++ ) {

return filtered;
};
}
function BrowserslistError(message) {
this.name = 'BrowserslistError';
this.message = message || '';
if ( Error.captureStackTrace ) {
Error.captureStackTrace(this, BrowserslistError);
}
}
BrowserslistError.prototype = Error.prototype;
function error(name) {
var obj = new BrowserslistError(name);
obj.browserslist = true;
throw obj;
}
// Return array of browsers by selection queries:

@@ -30,3 +45,3 @@ //

} else {
throw 'Can\'t read ' + file + ' config';
error('Can\'t read ' + file + ' config');
}

@@ -49,7 +64,13 @@ } else {

var query, match, array, used;
var exclude, query, match, array, used;
selections.forEach(function (selection) {
if ( selection.trim() === '' ) return;
used = false;
exclude = false;
used = false;
if ( selection.indexOf('not ') === 0 ) {
selection = selection.slice(4);
exclude = true;
}
for ( var i in browserslist.queries ) {

@@ -59,4 +80,10 @@ query = browserslist.queries[i];

if ( match ) {
array = query.select.apply(browserslist, match.slice(1));
result = result.concat(array);
array = query.select.apply(browserslist, match.slice(1));
if ( exclude ) {
result = result.filter(function (j) {
return array.indexOf(j) === -1;
});
} else {
result = result.concat(array);
}
used = true;

@@ -68,3 +95,3 @@ break;

if ( !used ) {
throw 'Unknown browser query `' + selection + '`';
error('Unknown browser query `' + selection + '`');
}

@@ -114,2 +141,4 @@ });

browserslist.Error = BrowserslistError;
// Will be filled by Can I Use data below

@@ -125,4 +154,3 @@ browserslist.data = { };

'last 2 versions',
'Firefox ESR',
'Opera 12.1'
'Firefox ESR'
];

@@ -132,3 +160,3 @@

browserslist.major = ['safari', 'opera', 'ios_saf', 'ie_mob', 'ie',
'firefox', 'chrome'];
'edge', 'firefox', 'chrome'];

@@ -163,3 +191,3 @@ // Browser names aliases

var data = browserslist.byName(name);
if ( !data ) throw 'Unknown browser ' + name;
if ( !data ) error('Unknown browser ' + name);
return data;

@@ -192,10 +220,9 @@ };

return string.toString()
.replace(/#[^\n]*/g, '')
.split(/\n/)
.map(function (i) {
return i.trim();
})
.filter(function (i) {
return i !== '';
});
.replace(/#[^\n]*/g, '')
.split(/\n/)
.map(function (i) {
return i.trim();
}).filter(function (i) {
return i !== '';
});
};

@@ -352,3 +379,3 @@

} else {
throw 'Unknown version ' + version + ' of ' + name;
error('Unknown version ' + version + ' of ' + name);
}

@@ -381,3 +408,3 @@ }

for ( var j = 0; j < interval.length; j++ ) {
browserslist.versionAliases[name][ interval[j] ] = full;
browserslist.versionAliases[name][interval[j]] = full;
}

@@ -387,4 +414,4 @@ }

}
})();
}());
module.exports = browserslist;
{
"name": "browserslist",
"version": "0.5.0",
"description": "Get browsers versions that matches given criterias like in Autoprefixer",
"keywords": ["caniuse", "browsers"],
"author": "Andrey Sitnik <andrey@sitnik.ru>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ai/browserslist.git"
},
"dependencies": {
"caniuse-db": "^1.0.30000214"
},
"devDependencies": {
"gulp-eslint": "0.14.0",
"gulp-mocha": "2.1.2",
"mocha": "2.2.5",
"chai": "3.0.0",
"gulp": "3.9.0"
},
"scripts": {
"test": "gulp"
}
"name": "browserslist",
"version": "1.0.0",
"description": "Get browsers versions that matches given criterias like in Autoprefixer",
"keywords": [
"caniuse",
"browsers"
],
"author": "Andrey Sitnik <andrey@sitnik.ru>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ai/browserslist.git"
},
"dependencies": {
"caniuse-db": "^1.0.30000281"
},
"bin": "./cli.js",
"devDependencies": {
"gulp-eslint": "1.0.0",
"gulp-mocha": "2.1.3",
"mocha": "2.3.0",
"chai": "3.2.0",
"gulp": "3.9.0"
},
"scripts": {
"test": "gulp"
}
}

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

browserslist('last 1 version, > 5%');
//=> ['and_chr 42', 'and_uc 9.9', 'chrome 43', 'chrome 42', 'firefox 38',
// 'ie 11', 'ie_mob 11', 'ios_saf 8.1-8.3', 'opera 30', 'safari 8']
//=> ['and_chr 44', 'and_uc 9.9', 'chrome 44', 'chrome 43', 'edge 1',
// 'firefox 40', 'firefox 39', 'ie 11', 'ie_mob 11', 'ios_saf 8.1-8.4',
// 'opera 30', 'safari 8']
```

@@ -25,3 +26,3 @@

4. If all methods will not give a result, Browserslist will use defaults:<br>
`> 1%, last 2 versions, Firefox ESR, Opera 12.1`.
`> 1%, last 2 versions, Firefox ESR`.

@@ -51,2 +52,4 @@ <a href="https://evilmartians.com/?utm_source=browserslist">

* `iOS 7`: the iOS browser version 7 directly.
* `not ie <= 8`: exclude browsers selected before by this query.
You can add `not ` to any query.

@@ -71,2 +74,3 @@ Blackberry and Android WebView will not be used in `last n versions`.

* `Explorer` or `ie` for Internet Explorer.
* `Edge` for Microsoft Edge.
* `iOS` or `ios_saf` for iOS Safari.

@@ -82,3 +86,41 @@ * `Opera` for Opera.

## Config File
Browserslist’s config should be named `browserslist` and have browsers queries
split by a new line. You can write a comment after `#`:
```yaml
# Browsers that we support
> 1%
Last 2 versions
IE 8 # sorry
```
Browserslist will check config in every directory in `config.path` path.
So, if tool with Browserslist process `app/styles/main.css`, you can put
config to root, `app/` or `app/styles`.
You can specify direct path to config by `config` option
or `BROWSERSLIST_CONFIG` environment variables.
## Environment Variables
If some tool use Browserslist inside, you can change browsers settings
by [environment variables]:
* `BROWSERSLIST` with browsers queries.
```sh
BROWSERSLIST="> 5%" gulp css
```
* `BROWSERSLIST_CONFIG` with path to config file.
```sh
BROWSERSLIST_CONFIG=./config/browserslist gulp css
```
[environment variables]: https://en.wikipedia.org/wiki/Environment_variable
## Usage

@@ -103,15 +145,6 @@

## Config File
For non-JS environment and debug purpose you can use CLI tool:
Browserslist’s config should be named `browserslist` and have browsers queries
split by a new line. You can write a comment after `#`:
```yaml
# Browsers that we support
> 1%
Last 2 versions
IE 8 # sorry
```sh
browserslist "> 1%, last 2 version"
```
You can specify direct path to config by `config` option.

Sorry, the diff of this file is not supported yet

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