npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

searcherer

v0.2.0

Published

Searches contents of files

Readme

 .d8888b.                                    888
d88P  Y88b                                   888
Y88b.                                        888
 "Y888b.    .d88b.   8888b.  888d888 .d8888b 88888b.   .d88b.  888d888 .d88b.  888d888
    "Y88b. d8P  Y8b     "88b 888P"  d88P"    888 "88b d8P  Y8b 888P"  d8P  Y8b 888P"
      "888 88888888 .d888888 888    888      888  888 88888888 888    88888888 888
Y88b  d88P Y8b.     888  888 888    Y88b.    888  888 Y8b.     888    Y8b.     888
 "Y8888P"   "Y8888  "Y888888 888     "Y8888P 888  888  "Y8888  888     "Y8888  888

Searcherer is a Node.js module for searching strings or files.

Build Status Dependency Status Dev Dependency Status License Release

Install

Install using npm:

$ npm install --save searcherer

You'll need to have at least Node.js 8 or newer.

If you want to use the command line interface you'll most likely want to install it globally so that you can run searcherer from anywhere:

$ npm install --global searcherer

CLI

Usage: searcherer [options] [files...]


Options:

  -V, --version              output the version number
  --no-color                 disables color output
  -c, --case-sensitive       enable case-sensitive search
  -d, --debug                enable debug level logging
  -e, --encoding <encoding>  specify encoding for input [utf8]
  -f, --filename <filename>  specify filename to process STDIN as [<text>]
  -p, --pattern <pattern>    search for pattern
  -s, --style <name>         specify style for output [default]
  -h, --help                 output usage information

API

The API has been designed to be just as simple to use as the CLI. It uses ECMAScript 2015's promises to handle the asynchronous flows of file reading (with Sync methods available as well) so you can keep your code nice and clean.

Each search result contains the following information:

| Property | Type | Description | | -------------- | ---------- | ----------------------------------------------------------------- | | columnNumber | Number | Column number at which the match was found | | dictionary | Dictionary | Dictionary to which the pattern responsible for the match belongs | | line | String | Complete line of text in which the match was found | | lineNumber | Number | Line number in relation to the whole string being searched | | match | String | Exact match that was found | | pattern | String | Pattern responsible for the match |

Searcherer.search(value, dictionary[, options])

Searches the specified value for the patterns within the specified dictionary using the options provided.

dictionary can either be a Dictionary instance or one or more of search patterns from which a Dictionary instance can be created.

Options

| Option | Description | Default | | ---------------- | ---------------------------------------------------------------------- | ------------ | | caseSensitive | Perform case-sensitive search on value | false | | filter | Function to be used to filter which dictionaries are included in search | All |

Examples

const Searcherer = require('searcherer');

const results = Searcherer.search('We love Searcherer! It is great for searching strings', 'search(er){0,2}');

console.log(results);

Searcherer.searchFile(filePath, dictionary[, options])

Searches the contents that are asynchronously read from the file at the specified path for the patterns within the specified dictionary using the options provided.

dictionary can either be a Dictionary instance or one or more of search patterns from which a Dictionary instance can be created.

The encoding option can be used to specify how the contents of the file are encoded.

Options

Has the same options as the standard Searcherer.search method but also supports the following additional options:

| Option | Description | Default | | ---------- | --------------------------------------------------- | -------- | | encoding | Encoding of the contents of the file to be searched | "utf8" |

Examples

const Searcherer = require('searcherer');

(async() => {
  const results = await Searcherer.searchFile('/path/to/file', 'search(er){0,2}', { caseSensitive: true });
  
  console.log(results);
})();

Searcherer.searchFileSync(filePath, dictionary[, options])

A synchronous version of the Searcherer.searchFile method.

Searcherer([options])

Creates an instance of Searcherer using the options provided.

The dictionary option can be specified to initialize Searcherer with a single Dictionary. It can be either a Dictionary instance or one or more of search patterns from which a Dictionary instance can be created.

While the static methods of Searcherer for searching work great, it's encouraged to create Searcherer instances when dealing with multiple dictionaries (collections of search patterns). Additionally, it's highly recommended that Dictionary instances are created when searching a large number of patterns and/or using the same patterns to search many different strings/files. Doing so will increase performance as regular expressions compiled from the patterns are cached.

The following instance methods exist to mirror the static methods for searching:

  • Searcherer#search(value[, options])
  • Searcherer#searchFile(filePath[, options])
  • Searcherer#searchFileSync(filePath[, options])

Additionally, the following instance methods exist that allow dictionaries to be added to a Searcherer instance:

  • Searcherer#addDictionary(dictionary)
  • Searcherer#addDictionaryFile(filePath)
  • Searcherer#addDictionaryFileSync(filePath)

Options

| Option | Description | Default | | ---------------- | --------------------------------------------------------------------- | ------------ | | dictionary | Initial Dictionary or the search pattern(s) to be used to create it | N/A | | dictionaryType | Dictionary implementation whose instances are to be created | Dictionary |

Events

Each of the search methods can emit the following events:

| Event | Description | | -------- | ----------------------------------------------- | | end | Fired once the search has completed | | result | Fired immediately when a search result is found | | search | Fired immediately before the value is searched |

Examples

const Searcherer = require('searcherer');
const { Dictionary } = Searcherer;

(async() => {
  const searcherer = new Searcher();
  searcherer.addDictionary(new Dictionary({ name: 'foo', patterns: [ ... ] ));
  searcherer.addDictionary(new Dictionary({ name: 'bar', patterns: [ ... ] ));
  
  const results = await searcherer.searchFile('/path/to/file', { caseSensitive: true });
  
  console.log(results);
})();

Bugs

If you have any problems with Searcherer or would like to see changes currently in development you can do so here.

Contributors

If you want to contribute, you're a legend! Information on how you can do so can be found in CONTRIBUTING.md. We want your suggestions and pull requests!

A list of Searcherer contributors can be found in AUTHORS.md.

License

See LICENSE.md for more information on our MIT license.

Copyright !ninja