bridgetownrb / node-runner Goto Github PK
View Code? Open in Web Editor NEWA simple way to execute Javascript in a Ruby context via Node
License: MIT License
A simple way to execute Javascript in a Ruby context via Node
License: MIT License
Hey,
I'm not much versed in JavaScript, but I think that this can be a good solution:
#{source}
try {
const args = #{args}
Promise.resolve(#{func}(...args)).then(result => {
const output = JSON.stringify(['ok', result, []])
process.stdout.write(output)
})
} catch (err) {
process.stdout.write(JSON.stringify(['err', '' + err, err.stack]))
}
I will write a PR with it, just would like to open the discussion.
Best regards!
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"
Here https://github.com/bridgetownrb/node-runner/blob/master/lib/node_runner.js#L3
We have wrapper try-catch
block.
But is there any specific reason why Promise.resolve()
doesn't have catch
clause?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.