tiny-fsearch
Fast and Simple File Search for NodeJS. Versatile find-in-files/search methods that can take in a range of options.
Getting Started
tiny-fsearch
is a native Node module available via NPM. It can be installed with.
$ npm install --save tiny-fsearch
Usage
The module consists of two available functions and promisified alternatives.
const tiny = require('tiny-fsearch');
tiny.fsearch(searchable, filePaths, options);
tiny.fquery(searchable, source, options);
tiny.promises.fsearch(...);
tiny.promises.fquery(...);
searchable [string|RegExp]
The string or RegExp to use for matching.
filePaths [string|string[]]
A file or file-paths to coordinate searching from (fsearch
only).
source [string|Buffer]
A source string or NodeJS Buffer to search from (fquery
only).
options [object]
The available options exposed for setting different search parameters.
interface ISearchOptions {
isRegex: boolean;
matchCase: boolean;
matchWholeWord: boolean;
zeroIndexing: boolean;
}
Both functions return similar hit-based results. For the fsearch
implementation a series of results will be return in an array, where as the fquery
returns only a singular result. The format of a search result is:
interface ISearchMatch {
filePath: string;
hits: {
content: string;
line: number;
column: number;
}[]
}
License
MIT