Skip to content

Need a package to get the ECMAScript version of a browser? You found it!

License

Notifications You must be signed in to change notification settings

gnodi/ecma-version

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@gnodi/ecma-version

[Node.js] Need a package to get the ECMAScript version of a browser? You found it!

Build Coverage Status Version Downloads Dependencies Dev Dependencies

## Installation

Run the following command to add the package to your dev dependencies:

$ npm install --save @gnodi/ecma-version

## Use

const ecmaVersion = require('@gnodi/ecma-version');

Get the ECMAScript version from a browser name and version

ecmaVersion.getFromBrowser('Firefox', 10); // Return 5
ecmaVersion.getFromBrowser('Firefox', 55); // Return 6

Get the ECMAScript version from a user agent

ecmaVersion.getFromUserAgent(
  'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36'
);

Get the ECMAScript version from a HTTP request object

const http = require('http');

http.createServer((req) => {
  const version = ecmaVersion.getFromRequest(req);

  console.log(version);
}).listen(3080);

Get the browser compatible version for an ECMAScript version

ecmaVersion.getBrowserCompatibleVersion('Firefox', 5); // Return 0
ecmaVersion.getBrowserCompatibleVersion('Firefox', 6); // Return 53
ecmaVersion.getBrowserCompatibleVersion('IE', 6); // Return null

LICENSE

MIT