Package Exports
- seafox
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (seafox) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Seafox
A blazing fast 100% spec compliant, self-hosted javascript parser written in Typescript.
Features
- Conforms to the standard ECMAScript® 2020 (ECMA-262 10th Edition) language specification
- Support for additional ECMAScript features for Web Browsers
- Optionally track syntactic node locations
- Emits an ESTree-compatible abstract syntax tree.
- No backtracking
- Low memory usage
- Very well tested (~30 000 unit tests with full code coverage)
- Lightweight - ~87 KB minified
Installation
npm install seafox --save-dev
API
Seafox generates AST
according to ESTree AST format, and can be used to perform syntactic analysis (parsing) of a JavaScript program, and with ES2015
and later a JavaScript program can be either a script or a module.
Seafox stricly follows the ECMA specifications so you have to specify whether to parse in parseScript
mode (the default) or in parseModule
mode.
This is the available options:
{
// The flag to enable start and end offsets and line/column location information to each node
loc: false;
// Disable web compatibility
disableWebCompat: false;
// The flag to attach raw property to each literal and identifier node
raw: false;
// Enabled directives
directives: false;
// The flag to allow return in the global scope
globalReturn: false;
// The flag to enable implied strict mode
impliedStrict: false;
// Enable non-standard parenthesized expression node
preserveParens: false;
}
Example usage:
import { parseScript, parseModule } from './seafox';
parseScript('({x: [y] = 0} = 1)');
parseModule('({x: [y] = 0} = 1)', { directives: true, raw: true });
What is Seafox?
This is my private parser code made public. It strictly conforms to the standard ECMAScript® 2020 (ECMA-262 10th Edition) language specification, and can not be used as an drop-in replacement for other parsers, because they are using a parse()
method as an common public API to parse javascript code.
Seafox uses either parseScript
or parseModule
.
The main focus for Seafox
is performance, and if you are soft hearted and / or can't understand super low level code - this parser isn't for you :)
I would recommend to use the Meriyah parser
instead of Seafox
if you need a parser that behave like other public parsers, and also if you are in need of performance even the fact that Seafox is 15 - 25 % faster than the mentioned parser.