Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Interface improvements: Reader instead of File and multiple scripts #43

Open
benmccann opened this issue Jun 15, 2015 · 1 comment
Open

Comments

@benmccann
Copy link

I'm trying to port some code over to JS Engine and have run into trouble in a couple cases

One of the scripts I have is a String, but JS Engine only takes a File. Internally, JS Engine takes this File and turns it into a FileReader. It'd be nice if it just took a Reader to start because then I could pass it a FileReader, StringReader, InputStreamReader, etc. The only thing here that we'd have to account for is taking a File gives us a script name, so we'd also want to add a parameter for an optional script name.

The second thing I've run into is that my code currently executes multiple scripts on the same engine. There's not a really good way to do that with JS Engine because a new engine is created for each script. I could probably just concatenate the scripts, but then it'd be harder to debug any errors because you'd get the line number for the concatenated script instead of the original file name and line number. Of course I'm doing this with the Javax engine. I don't know if there's a way to run multiple scripts in the same Node engine or not...

@pfgray
Copy link

pfgray commented Sep 24, 2016

I don't think switching toReader in the Engine interface is possible, since all the LocalEngine instances expect to be handed a script in the form of a path to a real file (Node, CommonNode, PhantomJs).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants