is-es-version
check if some source code uses syntax supported by an ES version
You can use this before eg. running Babel with a million transforms on a file. Note that this attempts to parse the file using acorn, so it is pretty slow; recommended to memoize the result!
Install
npm install is-es-version
Usage
var isEsVersion = // false // true
API
isEsVersion(src, version=5, opts={})
Check if src
is a source code string that is supported by the EcmaScript version version
. The default version is 5. Returns true if the syntax is supported by the given version; false if not.
Set opts.parser
to use a custom parser module, such as acorn-node.