bridgetownrb / node-runner

A simple way to execute Javascript in a Ruby context via Node
MIT License
32 stars 4 forks source link

Does node-runner use the same node instance? #4

Open aspirisen opened 5 months ago

aspirisen commented 5 months ago

Hello, I am interested if node-runner reuse the node instance between functions run?

# node is running and waiting for input?
runner = NodeRunner.new(
  <<~JAVASCRIPT
    const hello = (response) => {
      return `Hello? ${response}`
    }
  JAVASCRIPT
)

And do not bootstrap node on every function call

# These functions call do not launch node every time
runner.hello "Goodbye!"
runner.hello "Goodbye! 2"
jaredcwhite commented 5 months ago

@aspirisen There's no persistent process, it's a single execution to get the response back.

aspirisen commented 5 months ago

@jaredcwhite that mens that every time I call a function on runner - then new nodejs process has to bootstrap again, I think that can have affect performance.

Would you consider such new feature?