Last active
December 24, 2015 17:29
-
-
Save spencerwi/6836206 to your computer and use it in GitHub Desktop.
Start a quick Javascript repl with underscore preloaded using nodejs. Requires nodejs and npm-installed underscore.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var repl = require('repl'); | |
var __ = require('underscore')._; | |
var files = {}; | |
var jsonFiles = process.argv.slice(2); | |
jsonFiles.forEach(function(val) { | |
files[val] = JSON.parse(fs.readFileSync(val)); | |
}); | |
var shell = repl.start({ | |
prompt: "underscore> ", | |
input: process.stdin, | |
output: process.stdout | |
}); | |
shell.context.files = files; | |
shell.context.__ = __; // in Nodejs's repl, _ is a placeholder for "last result," so we need to use __ instead. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment