diff options
author | Josh W <josher19@users.sf.net> | 2012-04-17 03:03:30 +0800 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-04-18 15:21:56 +0200 |
commit | d2860a6c7dc3e99f94585a5748f3713b5f7634db (patch) | |
tree | 8aa96cc1986a86ad14408206ca9240450c9b8642 /doc | |
parent | 20143b359c78577861309302fb56e11ddfd7f2db (diff) | |
download | android-node-v8-d2860a6c7dc3e99f94585a5748f3713b5f7634db.tar.gz android-node-v8-d2860a6c7dc3e99f94585a5748f3713b5f7634db.tar.bz2 android-node-v8-d2860a6c7dc3e99f94585a5748f3713b5f7634db.zip |
doc: make readline example filter shorter
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/readline.markdown | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/api/readline.markdown b/doc/api/readline.markdown index 0fe7303d01..92ab7b54bb 100644 --- a/doc/api/readline.markdown +++ b/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) { |