Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doc: make readline example filter shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
josher19 authored and bnoordhuis committed Apr 18, 2012
1 parent 20143b3 commit d2860a6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/api/readline.markdown
Expand Up @@ -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) {
Expand Down

0 comments on commit d2860a6

Please sign in to comment.