parsejs 1.2.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 7

ParseJS

ParseJS is a JavaScript parser for Dart. It is well-tested and is reasonably efficient.

Example Usage

import 'package:parsejs/parsejs.dart';

void main() {
    new File('test.js').readAsString().then((String code) {
        Program ast = parsejs(code, filename: 'test.js')
        // Use the AST for something
    })
}

Options

The parsejs function takes the following optional arguments:

  • filename: An arbitrary string indicating where the source came from. For your convenience this will be available on Node.filename and on ParseError.filename.
  • firstLine: The line number to associate with the first line of code. Default is 1. Useful if code was extracted from an HTML file, and you prefer absolute line numbers.
  • handleNoise: If true, parser will try to ignore hash bangs and HTML comment tags surrounding the source code. Default is true.
  • annotate: If true, parser will initialize Node.parent, Scope.environment, and Name.scope, to simplify subsequent AST analysis. Default is true.
  • parseAsExpression: If true, the input will be parsed as an expression statement.

1.2.0 (2017-05-06)

  • Added an option to parse the input as an expression.

1.1.0 (2015-06-01)

  • Added visitor with one argument.

1.0.0 - 1.0.3

  • Initial version with some bugfixes releases.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  parsejs: ^1.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:parsejs/parsejs.dart';
  
Version Uploaded Documentation Archive
1.2.0 May 6, 2017 Go to the documentation of parsejs 1.2.0 Download parsejs 1.2.0 archive
1.1.0 Jun 1, 2015 Go to the documentation of parsejs 1.1.0 Download parsejs 1.1.0 archive
1.0.3 Dec 17, 2014 Go to the documentation of parsejs 1.0.3 Download parsejs 1.0.3 archive
1.0.2 Nov 24, 2014 Go to the documentation of parsejs 1.0.2 Download parsejs 1.0.2 archive
1.0.1 Nov 24, 2014 Go to the documentation of parsejs 1.0.1 Download parsejs 1.0.1 archive
1.0.0 Nov 24, 2014 Go to the documentation of parsejs 1.0.0 Download parsejs 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
14
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
7
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Health suggestions

Fix lib/src/ast_visitor.dart. (-0.50 points)

Analysis of lib/src/ast_visitor.dart reported 1 hint:

line 128 col 3: This function has a return type of 'T', but doesn't end with a return statement.

Format lib/src/ast.dart.

Run dartfmt to format lib/src/ast.dart.

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Package is getting outdated. (-58.36 points)

The package was released 82 weeks ago.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use parsejs.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
unicode >=0.0.8 <1.0.0 0.1.0
Transitive dependencies
lists 0.0.23