🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

caniuse-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caniuse-js

Check source code against a browser support matrix

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

node-caniuse

Chat

Check your JavaScript against the Can I Use database

Quick Start

npm install node-caniuse
var 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):

  • Android for old Android stock browser.
  • BlackBerry or bb for Blackberry browser.
  • Chrome for Google Chrome.
  • Firefox or ff for Mozilla Firefox.
  • Explorer or ie or InternetExplorer for Internet Explorer.
  • iOS or ios_saf for iOS Safari.
  • Opera for Opera.
  • Safari for desktop Safari.
  • OperaMobile or op_mob for Opera Mobile.
  • OperaMini or op_mini for Opera Mini.
  • ChromeAndroid or and_chr for Chrome for Android (mostly same as common Chrome).
  • FirefoxAndroid or and_ff for Firefox for Android.
  • ExplorerMobile or ie_mob for 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: '_'
});

License

MIT License

FAQs

Package last updated on 10 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts