caniuse-js v0.2.1
Quick Start
npm install node-caniusevar caniuse = require('node-caniuse');
caniuse({
files: './src/**/*.js',
browsers: {
Chrome: '>= 5',
Firefox: '>= 4',
InternetExplorer: '>= 9'
},
reporter: 'console'
});API Reference
#####caniuse(Object options [, Function callback]) -> Promise
The result (for both the resolved Promise and for the callback) is an Array where each element represents a file and it's bad tokens.
[{
"filename" : "path/to/file",
"tokens" : [{
token: "<invalid token>",
location: {...}
}]
}]Note: The callback and the promise are equivalent and can be used interchangeably.
> option.files
Type: Array String
Default: []
The files to be scanned by caniuse. Both the String and Array versions accept globs. E.g. ./src/**/*.js
> options.browsers
Type: Object
Default: {}
An object representing your browser support matrix in the following format:
{
<browser-name>: <browser-versions>
}browser versions can be specified in the following three ways:
- Direct selection -
[9, 10, 11]or'11' - Versions newer than -
'> 9'or'>= 8' - Versions with Global Usage greater than -
'> 10%'
browser names can be any of the following (case insensitive):
Androidfor old Android stock browser.BlackBerryorbbfor Blackberry browser.Chromefor Google Chrome.Firefoxorfffor Mozilla Firefox.ExplorerorieorInternetExplorerfor Internet Explorer.iOSorios_saffor iOS Safari.Operafor Opera.Safarifor desktop Safari.OperaMobileorop_mobfor Opera Mobile.OperaMiniorop_minifor Opera Mini.ChromeAndroidorand_chrfor Chrome for Android (mostly same as commonChrome).FirefoxAndroidorand_fffor Firefox for Android.ExplorerMobileorie_mobfor Internet Explorer Mobile.
> reporter
Type: String
Default: null
Specify the output format by choosing any of the node-caniuse reporters
caniuse({
files: './src/**/*.js',
browsers: { Chrome: '>= 5' },
reporter: 'console'
});> gobalIgnores
Type: Array
Default: []
Ignore tokens that are properties of of the specified objects. This is helpful if you have libraries that act as polyfills for native behavior.
caniuse({
files: './src/**/*.js',
browsers: { Chrome: '>= 5' },
gobalIgnores: '_'
});