dartjsengine 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

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


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");


  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:

  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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21


Detected platforms: Flutter, other

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

Health suggestions

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

Analysis of lib/src/function.dart reported 3 hints:

line 35 col 3: Avoid return types on setters.

line 78 col 7: DO use curly braces for all flow control structures.

line 80 col 7: DO use curly braces for all flow control structures.

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

Analysis of lib/src/JSEngine.dart reported 2 hints:

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

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

Fix lib/src/number.dart. (-1 points)

Analysis of lib/src/number.dart reported 2 hints:

line 1 col 8: Unused import: 'dart:math'.

line 2 col 8: Unused import: 'object.dart'.

Fix additional 6 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • lib/src/builtin/misc.dart (1 hint)
  • lib/src/context.dart (1 hint)
  • lib/src/builtin/builtin.dart (Run dartfmt to format lib/src/builtin/builtin.dart.)
  • lib/src/builtin/function_constructor.dart (Run dartfmt to format lib/src/builtin/function_constructor.dart.)
  • lib/src/object.dart (Run dartfmt to format lib/src/object.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.


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