Fast and simple file-in-file methods for NodeJS.
tiny-fsearch
exposes both a native Node module and cross-platform grep functionality. It can be installed via:
npm install tiny-fsearch
The module consists of both "sycnhronous" and "streamed" match outputs for single find-in-file queries.
// ES Syntax (other require is fine for CommonJS)
import { FSearch } from 'tiny-fsearch';
// predicates/resources
const predicate: string = 'search value';
const filePath: string = 'file-to-search';
/// Synchronous File-Searching
FSearch.Sync.query(predicate, { filePath });
FSearch.Sync.grep(predicate, { filePath });
/// Streamed File-Searching
FSearch.Stream.grep(predicate, { filePath });
interface FSearch.Options {
limit?: number;
isRegExp?: boolean;
ignoreCase?: boolean;
matchWholeWord?: boolean;
}
interface FSearch.Result {
line: number;
column: number;
content: string;
}