All Projects → cherow → Cherow

cherow / Cherow

Licence: isc
Very fast and lightweight, standards-compliant, self-hosted javascript parser with high focus on both performance and stability

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
ecmascript
72 projects

Projects that are alternatives of or similar to Cherow

Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (-55.17%)
Mutual labels:  tc39, parsing, performance
Buntis
A 100% compliant, self-hosted typescript parser that emits an ESTree-compatible AST
Stars: ✭ 90 (-94.15%)
Mutual labels:  tc39, parsing, performance
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (-85.9%)
Mutual labels:  tc39, parsing, performance
Binjs Ref
Reference implementation for the JavaScript Binary AST format
Stars: ✭ 399 (-74.07%)
Mutual labels:  parsing, performance
Web Tooling Benchmark
JavaScript benchmark for common web developer workloads
Stars: ✭ 290 (-81.16%)
Mutual labels:  node-js, performance
Seafox
A blazing fast 100% spec compliant, self-hosted javascript parser written in Typescript
Stars: ✭ 425 (-72.38%)
Mutual labels:  tc39, parsing
Node Xml2js
XML to JavaScript object converter.
Stars: ✭ 4,402 (+186.03%)
Mutual labels:  parsing, node-js
Powershell ipv4portscanner
Powerful asynchronus IPv4 port scanner for PowerShell
Stars: ✭ 117 (-92.4%)
Mutual labels:  performance
Svg
Composer and parser for SVG
Stars: ✭ 119 (-92.27%)
Mutual labels:  parsing
Venice
Coroutines, structured concurrency and CSP for Swift on macOS and Linux.
Stars: ✭ 1,501 (-2.47%)
Mutual labels:  performance
Bssom.net
A small, high performance, powerful serializer using bssom binary protocol
Stars: ✭ 117 (-92.4%)
Mutual labels:  performance
Formatfuzzer
FormatFuzzer is a framework for high-efficiency, high-quality generation and parsing of binary inputs.
Stars: ✭ 117 (-92.4%)
Mutual labels:  parsing
Tickprofiler
Profile your minecraft server: Find which entities and tile entities are making your server slow
Stars: ✭ 119 (-92.27%)
Mutual labels:  performance
Android Readthefuckingsourcecode
😜 记录日常的开发技巧,开发中遇到的技术重点、难点,各个知识点的总结,优质面试题等等。持续更新...
Stars: ✭ 1,665 (+8.19%)
Mutual labels:  performance
Dateutil
Useful extensions to the standard Python datetime features
Stars: ✭ 1,706 (+10.85%)
Mutual labels:  parsing
Js Class Fields Chinese Discussion
JavaScript的『class fields』提案中文讨论
Stars: ✭ 117 (-92.4%)
Mutual labels:  tc39
Template Compiler
Compile text/template / html/template to regular go code
Stars: ✭ 120 (-92.2%)
Mutual labels:  performance
Pepper Metrics
pepper metrics is a tool, it can helps you collect runtime performance use RED method, and then output as log / timeseries data, by default it use prometheus as datasource, grafana as UI
Stars: ✭ 119 (-92.27%)
Mutual labels:  performance
Xamarin Forms Perf Playground
Xamarin.Forms Performance Playground (Layouts, Bindings, XAMLC, etc)
Stars: ✭ 119 (-92.27%)
Mutual labels:  performance
Easy.logger
A modern, high performance cross platform wrapper for Log4Net.
Stars: ✭ 118 (-92.33%)
Mutual labels:  performance

Cherow

NPM version Gitter chat CircleCI Coverage Status Commitizen friendly Code Quality: Javascript Total Alerts

A very fast and lightweight, standards-compliant, self-hosted javascript parser with high focus on both performance and stability.

Deprecation notice

This project is no longer maintained. Please consider its successor: meriyah and buntis

Demo and Benchmark

Features

  • Conforms to the standard ECMAScript® 2020 (ECMA-262 10th Edition) language specification (draft)
  • Support stage 3 proposals via option.
  • Support for parsing with and without web compability (AnnexB)
  • Support to only parse expressions
  • Experimental feature support via option.
  • Optionally track syntactic node locations
  • Emits an ESTree-compatible abstract syntax tree.
  • Very well tested (~25 000 unit tests with full code coverage))
  • Supports all module loaders
  • Lightweight - ~72 KB minified

ESNext features

Stage 3 features support. These need to be enabled with the next option.

API

Cherow 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.

The parse method exposed by Cherow takes an optional options object which allows you to specify whether to parse in script mode (the default) or in module mode.

Here is a quick example to parse a script:

cherow.parseScript('foo = bar');

// or

cherow.parse('x = async() => { for await (x of xs); }');

This will return when serialized in json:

{
    body: [{
        expression: {
            left: {
                name: 'x',
                type: 'Identifier'
            },
            operator: '=',
            right: {
                async: true,
                body: {
                    body: [{
                        await: true,
                        body: {
                            type: 'EmptyStatement',
                        },
                        left: {
                            name: 'x',
                            type: 'Identifier',
                        },
                        right: {
                            name: 'xs',
                            type: 'Identifier',
                        },
                        type: 'ForOfStatement',
                    }],
                    type: 'BlockStatement'
                },
                expression: false,
                generator: false,
                id: null,
                params: [],
                type: 'ArrowFunctionExpression'
            },
            type: 'AssignmentExpression'
        },
        type: 'ExpressionStatement'
    }],
    sourceType: 'script',
    type: 'Program'
}

The API also allows you to use Cherow as a stand-alone expression parser and let you parse your code in either script or module goal code.

cherow.parseExpression('foo', { ranges: true });

This will return when serialized in json:

 {
      end: 3,
      name: 'foo',
      start: 0,
      type: 'Identifier'
    }

Options

The second argument allows you to specify various options:

Option Description
module Enable module syntax
ranges Append start and end offsets to each node
globalReturn Allow return in the global scope
globalAwait Allow await in the global scope
webcompat Enable web compability (AnnexB)
impliedStrict Enable strict mode initial enforcement
next Enable stage 3 support (ESNext)
experimental Enable experimental features
parenthesizedExpr Enable non-standard parenthesized expression node
raw Attach raw property to each literal node and identifier node
directives Enable directive prologue to each literal node
onComment Accept either callback or array to collect comment
onToken Accept either callback or array and returns each found token

Experimental features

Cherow aim to support the same experimental features as found in V8 when enabling the 'experimental' flag. However. An exception has been made for the numeric separators proposal. It's currently pending on Stage 2 after being "degraded" from Stage 3. The future of this proposal seems uncertain at the moment and will not be implemented.

Also the proposal-decorators are constantly changing so at current stage this will not be implemented.

Nightly builds

It's available on NPM.

Contributing

If you feel something could've been done better, please do feel free to file a pull request with the changes.

Read our guidelines here

Bug reporting

If you caught a bug, don't hesitate to report it in the issue tracker. From the moment I respond to you, it will take maximum 60 minutes before the bug is fixed.

Note that I will try to respond to you within one hour. Sometimes it can take a bit longer. I'm not allways online. And if I find out it will take more then 60 minutes to solve your issue, you will be notified.

I know how irritating it can be if you are writing code and encounter bugs in your dependencies. And even more frustrating if you need to wait weeks or days.

Rationale

Existing parsers have many issues with them:

  • Acorn is the most commonly used tool out there because of its support for recent ES standards, but it's slow and it often is too permissive in what it accepts. It's also not optimized for handheld devices.

  • Esprima is a little faster than Acorn, but it's almost never updated, and their test suite has too many invalid tests. It also doesn't support recent ES standards.

  • Babylon is tightly coupled to Babel, and is comparatively very slow.

Most of these parsers would not fare any chance against the official Test262 suite, and fail a substantial number of them.

We figured we could try do better. We are used in plural form because Cherow is developed by a main developer and two others "behind the scenes" that contributes with their knowledge whenever it's necessary.


Cross-browser testing provided by:

BrowserStack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].