is-es-version
check if some source code uses syntax supported by an ES version
Last updated a year ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-es-version 
SYNC missed versions from official npm registry.

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!

npm travis standard

Install

npm install is-es-version

Usage

var isEsVersion = require('is-es-version')

isEsVersion('const a = 10', 5) // false
isEsVersion('var a = 10', 5) // 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.

isEsVersion('#!/usr/bin/env node\nrequire("./lib/cli")', 5, { parser: require('acorn-node') })

License

Apache-2.0

Current Tags

  • 1.2.0                                ...           latest (a year ago)

3 Versions

  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |