'How to execute dart generated javascript from dart

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.

Any suggestions?

Edit for reasoning:

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.

Future<List<Map>> 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) => i.chapter == chapter.id));
  }
  for (final paragraph in paragraphs) {
    paragraph.children = [];

    paragraph.children!
        .addAll(sentences.where((i) => i.paragraph == paragraph.id));
  }
  for (final sentence in sentences) {
    sentence.children = [];
    sentence.children!
        .addAll(textChunks.where((i) => i.sentence == sentence.id));
  }

  final Map<String, List<dynamic>> chapterOutput = {};
  final Map<String, List<dynamic>> audioOutput = {};

  for (final String language in languages) {
    chapterOutput[language] =
        chapters.where((chapter) => chapter.language == language).toList();
    chapterOutput[language]!.sort((a, b) => a.number!.compareTo(b.number!));
    audioOutput[language] =
        audioChunks.where((chunk) => chunk.language == language).toList();

    audioOutput[language]!.sort((a, b) => a.number!.compareTo(b.number!));
  }
  return [chapterOutput, audioOutput];
}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source