dartjsengine 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 49

dartJSEngine #

If for some reason you need to run JS code in your dart code, then this is, one of your bet. I have almost not written a single line of code for this, instead this is based on : https://github.com/samurai-dart/samurai and https://github.com/anuragvohraec/parsejs.dart

Had to rewrite/refactor this as the original projects where not updated to cater dart 2.4.

1.0.1 - 6 Aug 2019 #

Removed unwanted dependecies, like console, which was primary used for repl purpose

1.0.0 - 6 Aug 2019 #

JS engine written in dart. Code straightaway copied from : https://github.com/samurai-dart/samurai It was rewritten to make it fully compatiable with Dart 2.4. last commit on original project was 3 years back. Publishing to pub.dev without git branch was creating issues

example/example.dart

import 'package:jsparser/jsparser.dart';
import 'package:dartjsengine/dartjsengine.dart';

main() {
  var jsengine = new JSEngine();
  var program = parsejs("""
  function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}

Car.prototype.info = function(i) {
  return i+' You are driving a ' + this.year + ' ' + this.make + ' ' + this.model + '.';
};

  var car1 = new Car('Eagle', 'Talon TSi', 1993);
  """, filename: 'car.js');

  var program2 = parsejs("""car1.info(1);""",filename: "test.js");

  jsengine.visitProgram(program);

  for(var i =0 ; i< 100000; i++){
    var result = jsengine.visitProgram(program2);
    print('$i ${result?.valueOf}');
  }

}

Use this package as a library

1. Depend on it

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


dependencies:
  dartjsengine: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dartjsengine/dartjsengine.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
58
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Dec 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:dartjsengine/dartjsengine.dart with components: io.

Health suggestions

Fix lib/src/JSEngine.dart. (-21.78 points)

Analysis of lib/src/JSEngine.dart reported 49 hints, including:

line 6 col 1: Prefer using /// for doc comments.

line 14 col 45: Unnecessary new keyword.

line 15 col 27: Unnecessary new keyword.

line 24 col 3: Prefer using /// for doc comments.

line 36 col 19: Unnecessary new keyword.

Fix lib/src/builtin/misc.dart. (-11.78 points)

Analysis of lib/src/builtin/misc.dart reported 25 hints, including:

line 7 col 27: Unnecessary new keyword.

line 9 col 14: Unnecessary new keyword.

line 17 col 3: Unnecessary new keyword.

line 19 col 14: Unnecessary new keyword.

line 25 col 27: Unnecessary new keyword.

Fix lib/src/function.dart. (-4.41 points)

Analysis of lib/src/function.dart reported 9 hints, including:

line 17 col 28: Unnecessary new keyword.

line 18 col 26: Unnecessary new keyword.

line 19 col 31: Unnecessary new keyword.

line 35 col 3: Avoid return types on setters.

line 35 col 55: Unnecessary new keyword.

Fix additional 12 files with analysis or formatting issues. (-12.96 points)

Additional issues in the following files:

  • lib/src/stack.dart (5 hints)
  • lib/src/builtin/boolean_constructor.dart (4 hints)
  • lib/src/util.dart (4 hints)
  • lib/src/array.dart (2 hints)
  • lib/src/builtin/function_constructor.dart (2 hints)
  • lib/src/builtin/functions.dart (2 hints)
  • lib/src/context.dart (2 hints)
  • lib/src/number.dart (2 hints)
  • lib/src/object.dart (2 hints)
  • lib/src/arguments.dart (1 hint)
  • lib/src/builtin/builtin.dart (Run dartfmt to format lib/src/builtin/builtin.dart.)
  • lib/src/string.dart (Run dartfmt to format lib/src/string.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
jsparser ^2.0.1 2.0.1
symbol_table ^2.0.0 2.0.0
Transitive dependencies
lists 0.1.3
unicode 0.2.2
Dev dependencies
test ^1.6.5