title: How to execute dart generated javascript from dart
body: <p>I have this dart script that I compiled to javascript. How do I go about calling this javascript from dart? I'm trying to eventually call this from a web worker, but my javascript is really rusty, and I was hoping to use this as its more maintainable for me.</p>
  <p>Any suggestions?</p>
  <p>Edit for reasoning:</p>
  <p>The reason I would like to do it this way so that I can call this as a web worker from Dart, as this is a computationally expensive task to do. I'd prefer avoiding writing a plugin since I'm able to call the compute function on this code, which for all but web, is performant. So if I can figure out a way to do this without writing any JS, that would be preferable.</p>
  <pre><code>Future&lt;List&lt;Map&gt;&gt; main(
      {dynamic chapters,
      dynamic paragraphs,
      dynamic sentences,
      dynamic textChunks,
      dynamic audioChunks,
      dynamic languages}) async {
    for (final chapter in chapters) {
      chapter.children = [];
      chapter.children!.addAll(paragraphs.where((i) =&gt; i.chapter == chapter.id));
    }
    for (final paragraph in paragraphs) {
      paragraph.children = [];
  
      paragraph.children!
          .addAll(sentences.where((i) =&gt; i.paragraph == paragraph.id));
    }
    for (final sentence in sentences) {
      sentence.children = [];
      sentence.children!
          .addAll(textChunks.where((i) =&gt; i.sentence == sentence.id));
    }
  
    final Map&lt;String, List&lt;dynamic&gt;&gt; chapterOutput = {};
    final Map&lt;String, List&lt;dynamic&gt;&gt; audioOutput = {};
  
    for (final String language in languages) {
      chapterOutput[language] =
          chapters.where((chapter) =&gt; chapter.language == language).toList();
      chapterOutput[language]!.sort((a, b) =&gt; a.number!.compareTo(b.number!));
      audioOutput[language] =
          audioChunks.where((chunk) =&gt; chunk.language == language).toList();
  
      audioOutput[language]!.sort((a, b) =&gt; a.number!.compareTo(b.number!));
    }
    return [chapterOutput, audioOutput];
  }
  
  </code></pre>