Node's REPL features include _ to refer to the last value as well as a few commands starting with a period [1]. I've found these to really interfere with day-to-day development and experimentation: at least the n_ executable [2] allows one to use _ as lodash, but I haven't found a similar workaround to the special commands like .break and .save, which cause Node REPL to reject pasted code using the following code formatting:
var a = fs.readFileSync('file', 'utf8')
.split('\n')
.filter(s => s.search(' : ') >= 0)
.map(s => s.replace(/ /g, '').split(':'));
Node REPL fails to parse this valid JavaScript snippet because it doesn't have special commands ".split" or ".filter", etc. One really roundabout workaround: I run a regexp in my editor to move the dot from the beginning of the line to the end of the previous line, just so I can copy-paste (or in my case, send to tmux). But as soon as I re-run clang-format, the above REPL-incompatible formatting is reinstated, making this workaround really insufferable.
Is it feasible to disable these special commands, by either launching a custom Node REPL, or even by editing the Node source? Any tips or pitfalls to watch out for would be appreciated. Many thanks,
Ahmed
[1]
https://nodejs.org/api/repl.html#repl_repl_features[2]
https://www.npmjs.com/package/n_