Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-fsearch

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-fsearch

A small and versatile find-in-file/source library.

  • 1.0.1
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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');

/// File searching.
tiny.fsearch(searchable, filePaths, options);

/// Source String/Buffer query method.
tiny.fquery(searchable, source, options);

/// Promisified alternatives
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;           // Denotes is using RegExp string. Toggled true if method is given RegExp object as searchable.
    matchCase: boolean;         // Case sensitivity of searching.
    matchWholeWord: boolean;    // Wraps internal RegExp logic with zero-width boundary characters (\b).
    zeroIndexing: boolean;      // Returns results with zero-indexing.
}

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;       // `fsearch` only.
    hits: {
        content: string;    // Line content of match.
        line: number;       // Originating line number.
        column: number;     // Originating column number.
    }[]
}

License

MIT

FAQs

Package last updated on 30 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc