Skip to content

Instantly share code, notes, and snippets.

@spencerwi
Last active December 24, 2015 17:29
Show Gist options
  • Save spencerwi/6836206 to your computer and use it in GitHub Desktop.
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.
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