Browse Source

doc: make readline example filter shorter

v0.9.1-release
Josh W 13 years ago
committed by Ben Noordhuis
parent
commit
d2860a6c7d
  1. 9
      doc/api/readline.markdown

9
doc/api/readline.markdown

@ -49,6 +49,15 @@ is supposed to return an Array with 2 entries:
Which ends up looking something like:
`[[substr1, substr2, ...], originalsubstring]`.
Example:
function completer(line) {
var completions = '.help .error .exit .quit .q'.split(' ')
var hits = completions.filter(function(c) { return c.indexOf(line) == 0 })
// show all completions if none found
return [hits.length ? hits : completions, line]
}
Also `completer` can be run in async mode if it accepts two arguments:
function completer(linePartial, callback) {

Loading…
Cancel
Save