js-browser-compat-data
v1.0.5
Published
Useful to check a JS methods browser compatibility
Downloads
4
Maintainers
Readme
js-browser-compat-data
Checks JS browsers compatibilities based on mdn-browser-compat-data
Installation
$ npm i js-browser-compat-data
Usage
const jsCompat = require('js-browser-compat-data');
// or
import * as jsCompat from 'js-browser-compat-data';
jsCompat.find('includes'); // ['builtins.Array.includes','builtins.String.includes','builtins.TypedArray.includes']
jsCompat.getSupport('builtins.Array.includes');
jsCompat.isSupported('builtins.Array.includes', 'ie'); //false
jsCompat.minimumSupportedVersion('builtins.Array.includes', 'chrome'); //47
jsCompat.getStatus('builtins.Array.includes'); // { experimental: false, standard_track: true, deprecated: false }
jsCompat.getMDNLink('builtins.Array.includes'); // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
jsCompat.allFeatures(); // ['builtins.Array.concat', 'builtins.Array.copyWithin', 'builtins.Array.entries', ...]
API
jsCompat.find(searchKey)
get all the methods for the particular search key
Returns an array of all available JS methods with the given search key. If none of them matches, it returns an empty array.
jsCompat.find('includes');
/*
['builtins.Array.includes', 'builtins.String.includes', 'builtins.TypedArray.includes']
*/
jsCompat.getSupport(feature)
ask since which browser version the feature is available
Returns an array of object containing the support for the most used browsers. If the feature name is incorrect, it returns an empty array
jsCompat.getSupport('builtins.Array.includes');
/*
[
{ chrome: { support: true, version: '47' } },
{ chrome_android: { support: true, version: '47' } },
{ edge: { support: true, version: '14' } },
{ firefox: { support: true, version: '43' } },
{ firefox_android: { support: true, version: '43' } },
{ ie: { support: false } },
{ nodejs: { support: true, version: '6.0.0' } },
{ opera: { support: true, version: '34' } },
{ opera_android: { support: true, version: '34' } },
{ safari: { support: true, version: '9' } },
{ safari_ios: { support: true, version: '9' } },
{ samsunginternet_android: { support: true, version: '5.0' } },
{ webview_android: { support: true, version: '47' } }
]
*/
jsCompat.isSupported(feature, browser)
ask if the feature is supported in a particular browser. The list of browsers are shown above in the previous example
Returns true if the feature is supported, else it returns false.
jsCompat.isSupported('builtins.Array.includes', 'ie'); // false
jsCompat.isSupported('builtins.Array.includes', 'chrome'); // true
jsCompat.minimumSupportedVersion(feature, browser)
get the minium version of the browser that supports the feature
Returns the supported version, if supported, else return false.
jsCompat.minimumSupportedVersion('builtins.Array.includes', 'chrome'); //47
jsCompat.minimumSupportedVersion('builtins.Array.includes', 'ie'); //false
jsCompat.getStatus(feature)
get the current status of the feature, if it is experimental or deprecated or used as standard
Returns an object of all these three properties with true/false for each property. Returns and empty object if there is no such feature.
jsCompat.getStatus('builtins.Array.includes');
/*
{ experimental: false, standard_track: true, deprecated: false }
*/
jsCompat.getMDNLink(feature)
gets the link to the mdn page for the feature
Returns the URL as the response, else returns empty string if there is no such feature.
jsCompat.getMDNLink('builtins.Array.includes');
/*
https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
*/
jsCompat.allFeatures()
lists all the features that are available in JS
Returns an array of all the available features in JS.
jsCompat.allFeatures();
// ['builtins.Array.concat', 'builtins.Array.copyWithin', 'builtins.Array.entries', ...]
Issues?
If you find a problem, please file a bug.
Note
Though this can be used as a client package, we recommend you to use this as a Node package as it will be in sync with the MDN DB.