seek is a function that allows to recursively search through files in a directory. It's perfect for providing a search form on your website if the website does only consist of static files.
directoryis the pathname of a readable directory.
queryis either a string consisting of the keywords to search for or an array of strings and regular expressions.
optionsis an object that redefines some of the default properties.
The default options are as follows:recursive: true // - Recursive file walking. If set to false,// subdirectories of directory will be ignored.caseSensitive: false // - Case insensitive searchdotFiles: true // - Don't ignore "dot files" like '.gitignore'requireAll: true // - Require to find all keywords so that a file is// matched.findAll: false // - Only the first occurrence of a keyword is// matched. Set this to true, if you want to match// all occurrences of a keyword in the file.ignoreOrder: true // - Ignore the order of the keywords. Use with// care! Only works with findAll set to false.separator: ' ' // - String, which separates the keywords query if// query is a string.bufferSize: 64 * 1024 // - The buffer size used (twice) for a file.// Decrease this value for a smaller memory// footprint when you are seeking for large files.
foundis passed two arguments
fileis the pathname of the file that has been found and
matchesis an array. The array may contain objects or arrays. The objects are returned when you search for strings. They look something like this:keyword: 'foo' // - the keyword that has been foundfirstIndex: 43 // - the index of the first character of the keyword in// the filelastIndex: 45 // - the index of the last character of the keyword in the// file
The arrays look like the regular results of a regular expression match. They only occur when
queryis an array and contains a regular expression.
filter [optional]is passed one argument
(file). You may filter files out by providing a condition in this file. A file is left out, if
complete [optional]is passed no arguments. This callback is called, when the search is over.
npm install -g seek
var seek = ;;
For more examples, look at the tests.
Bugs and Issues
If you encounter any bugs or issues, feel free to open an issue at github.