Ryan Duffy 1c13800efd Use fromCodePoint to convert high value unicode entities (#243)
* Use fromCodePoint to convert high value unicode entities

* Include polyfill for String.fromCodePoint

* copy and adapt fromCodePoint into String.fromcodepoint

In order to avoid modifying String as the polyfill does, I've copied
the source from the polyfill and adapted it return the polyfill
function if the native version does not exist. Once support for node
versions that lack fromCodePoint is dropped, this polyfill can be
removed.

* move license notice to top of file
2017-01-02 10:15:56 +01:00
2016-11-01 16:51:12 +01:00
2016-06-22 14:35:19 +02:00
2017-01-02 09:57:55 +01:00
2016-10-14 12:12:55 -04:00
2016-10-14 12:12:55 -04:00
2017-01-02 09:57:55 +01:00
2015-07-30 12:57:23 +01:00
2016-11-17 19:08:57 -05:00
2016-03-10 06:24:44 +00:00
2015-07-30 12:57:23 +01:00
2016-11-14 18:16:36 +01:00
2017-01-02 09:57:55 +01:00
2017-01-02 10:00:13 +01:00

babylon

Babylon is a JavaScript parser used in Babel.

Travis Status Codecov Status

  • The latest ECMAScript version enabled by default (ES2017).
  • Comment attachment.
  • Support for JSX and Flow.
  • Support for experimental language proposals (accepting PRs for anything at least stage-0).

Credits

Heavily based on acorn and acorn-jsx, thanks to the awesome work of @RReverser and @marijnh.

Significant diversions are expected to occur in the future such as streaming, EBNF definitions, sweet.js integration, interspatial parsing and more.

API

babylon.parse(code, [options])

Options

  • allowImportExportEverywhere: By default, import and export declarations can only appear at a program's top level. Setting this option to true allows them anywhere where a statement is allowed.

  • allowReturnOutsideFunction: By default, a return statement at the top level raises an error. Set this to true to accept such code.

  • allowSuperOutsideMethod TODO

  • sourceType: Indicate the mode the code should be parsed in. Can be either "script" or "module".

  • sourceFilename: Correlate output AST nodes with their source filename. Useful when generating code and source maps from the ASTs of multiple input files.

  • plugins: Array containing the plugins that you want to enable.

Output

Babylon generates AST according to Babel AST format. It is based on ESTree spec with the following deviations:

AST for JSX code is based on Facebook JSX AST with the addition of one node type:

  • JSXText

Semver

Babylon follows semver in most situations. The only thing to note is that some spec-compliancy bug fixes may be released under patch versions.

For example: We push a fix to early error on something like #107 - multiple default exports per file. That would be considered a bug fix even though it would cause a build to fail.

Example

require("babylon").parse("code", {
  // parse in strict mode and allow module declarations
  sourceType: "module",

  plugins: [
    // enable jsx and flow syntax
    "jsx",
    "flow"
  ]
});

Plugins

  • jsx
  • flow
  • doExpressions
  • objectRestSpread
  • decorators
  • classProperties
  • exportExtensions
  • asyncGenerators
  • functionBind
  • functionSent
  • dynamicImport
Description
No description provided
Readme 79 MiB
Languages
JavaScript 99.5%
Makefile 0.3%
HTML 0.1%