Allows you to execute JavaScript code in a REPL environment directly from Sublime Text.
This build system gives you access to everything you would expect to have access to with any typical Node script/application. For more advanced applications that expect some sort of user/client interactions, this may not work well (or at all), but it's great for testing snippets of code for instant feedback.
Save the Node.sublime-build
file to Sublime's Packages/User
folder. In order to run ("build") some JavaScript, it must be saved as a file somewhere. Then select "Node" as the build system and press ⌘B to run the active tab in Node.
function head(xs) {
return xs[0]
}
function tail(xs) {
return xs.length ? xs.slice(1) : []
}
function sum(ns) {
var n = head(ns), ns = tail(ns)
return ns.length ? n + sum(ns) : n
}
console.log(sum([1,2,3,4,5]))
15
[Finished in 0.0s]