How is autocomplete shadow in nodejs implemented as a console application?
By "autocomplete shadow" I mean ... as I type in the node REPL 'func' without hitting tab I get a shadow of the keyword 'function':
How can I do this in my own console app:
// Simple REPL with tab completion ... how to make it into a REPL with shadow completion?
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
completer: (line) => { // This will only give me tab completion
const completions = ['function', 'let', 'const']
const hits = completions.filter(completion => completion.startsWith(line))
return [hits.length ? hits : completions, line]
}
})
rl.prompt()
rl.on('line', input => {
console.log(input)
rl.prompt()
})
