{"id":19807619,"url":"https://github.com/notninja/searcherer","last_synced_at":"2026-05-11T01:22:39.709Z","repository":{"id":65493608,"uuid":"108192087","full_name":"NotNinja/searcherer","owner":"NotNinja","description":"Searches contents of files","archived":false,"fork":false,"pushed_at":"2017-11-07T17:17:50.000Z","size":56,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-11T13:30:11.371Z","etag":null,"topics":["file","javascript","nodejs","search"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotNinja.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-24T22:46:59.000Z","updated_at":"2017-10-25T23:27:04.000Z","dependencies_parsed_at":"2023-01-25T21:05:12.261Z","dependency_job_id":null,"html_url":"https://github.com/NotNinja/searcherer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNinja%2Fsearcherer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNinja%2Fsearcherer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNinja%2Fsearcherer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotNinja%2Fsearcherer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotNinja","download_url":"https://codeload.github.com/NotNinja/searcherer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241150645,"owners_count":19918353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file","javascript","nodejs","search"],"created_at":"2024-11-12T09:11:27.737Z","updated_at":"2026-05-11T01:22:39.661Z","avatar_url":"https://github.com/NotNinja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"     .d8888b.                                    888\n    d88P  Y88b                                   888\n    Y88b.                                        888\n     \"Y888b.    .d88b.   8888b.  888d888 .d8888b 88888b.   .d88b.  888d888 .d88b.  888d888\n        \"Y88b. d8P  Y8b     \"88b 888P\"  d88P\"    888 \"88b d8P  Y8b 888P\"  d8P  Y8b 888P\"\n          \"888 88888888 .d888888 888    888      888  888 88888888 888    88888888 888\n    Y88b  d88P Y8b.     888  888 888    Y88b.    888  888 Y8b.     888    Y8b.     888\n     \"Y8888P\"   \"Y8888  \"Y888888 888     \"Y8888P 888  888  \"Y8888  888     \"Y8888  888\n\n[Searcherer](https://github.com/NotNinja/searcherer) is a [Node.js](https://nodejs.org) module for searching strings or\nfiles.\n\n[![Build Status](https://img.shields.io/travis/NotNinja/searcherer/develop.svg?style=flat-square)](https://travis-ci.org/NotNinja/searcherer)\n[![Dependency Status](https://img.shields.io/david/NotNinja/searcherer.svg?style=flat-square)](https://david-dm.org/NotNinja/searcherer)\n[![Dev Dependency Status](https://img.shields.io/david/dev/NotNinja/searcherer.svg?style=flat-square)](https://david-dm.org/NotNinja/searcherer?type=dev)\n[![License](https://img.shields.io/npm/l/searcherer.svg?style=flat-square)](https://github.com/NotNinja/searcherer/blob/master/LICENSE.md)\n[![Release](https://img.shields.io/npm/v/searcherer.svg?style=flat-square)](https://www.npmjs.com/package/searcherer)\n\n* [Install](#install)\n* [CLI](#cli)\n* [API](#api)\n* [Bugs](#bugs)\n* [Contributors](#contributors)\n* [License](#license)\n\n## Install\n\nInstall using `npm`:\n\n``` bash\n$ npm install --save searcherer\n```\n\nYou'll need to have at least [Node.js](https://nodejs.org) 8 or newer.\n\nIf you want to use the command line interface you'll most likely want to install it globally so that you can run\n`searcherer` from anywhere:\n\n``` bash\n$ npm install --global searcherer\n```\n\n## CLI\n\n    Usage: searcherer [options] [files...]\n    \n    \n    Options:\n    \n      -V, --version              output the version number\n      --no-color                 disables color output\n      -c, --case-sensitive       enable case-sensitive search\n      -d, --debug                enable debug level logging\n      -e, --encoding \u003cencoding\u003e  specify encoding for input [utf8]\n      -f, --filename \u003cfilename\u003e  specify filename to process STDIN as [\u003ctext\u003e]\n      -p, --pattern \u003cpattern\u003e    search for pattern\n      -s, --style \u003cname\u003e         specify style for output [default]\n      -h, --help                 output usage information\n\n## API\n\nThe API has been designed to be just as simple to use as the CLI. It uses ECMAScript 2015's promises to handle the\nasynchronous flows of file reading (with `Sync` methods available as well) so you can keep your code nice and clean.\n\nEach search result contains the following information:\n\n| Property       | Type       | Description                                                       |\n| -------------- | ---------- | ----------------------------------------------------------------- |\n| `columnNumber` | Number     | Column number at which the match was found                        |\n| `dictionary`   | Dictionary | Dictionary to which the pattern responsible for the match belongs |\n| `line`         | String     | Complete line of text in which the match was found                |\n| `lineNumber`   | Number     | Line number in relation to the whole string being searched        |\n| `match`        | String     | Exact match that was found                                        |\n| `pattern`      | String     | Pattern responsible for the match                                 |\n\n### `Searcherer.search(value, dictionary[, options])`\n\nSearches the specified `value` for the patterns within the specified `dictionary` using the `options` provided.\n\n`dictionary` can either be a `Dictionary` instance or one or more of search patterns from which a `Dictionary` instance\ncan be created.\n\n#### Options\n\n| Option           | Description                                                            | Default      |\n| ---------------- | ---------------------------------------------------------------------- | ------------ |\n| `caseSensitive` | Perform case-sensitive search on `value`                                | `false`      |\n| `filter`        | Function to be used to filter which dictionaries are included in search | *All*        |\n\n#### Examples\n\n``` javascript\nconst Searcherer = require('searcherer');\n\nconst results = Searcherer.search('We love Searcherer! It is great for searching strings', 'search(er){0,2}');\n\nconsole.log(results);\n```\n\n### `Searcherer.searchFile(filePath, dictionary[, options])`\n\nSearches the contents that are asynchronously read from the file at the specified path for the patterns within the\nspecified `dictionary` using the `options` provided.\n\n`dictionary` can either be a `Dictionary` instance or one or more of search patterns from which a `Dictionary` instance\ncan be created.\n\nThe `encoding` option can be used to specify how the contents of the file are encoded.\n\n#### Options\n\nHas the same options as the standard `Searcherer.search` method but also supports the following additional options:\n\n| Option     | Description                                         | Default  |\n| ---------- | --------------------------------------------------- | -------- |\n| `encoding` | Encoding of the contents of the file to be searched | `\"utf8\"` |\n\n#### Examples\n\n``` javascript\nconst Searcherer = require('searcherer');\n\n(async() =\u003e {\n  const results = await Searcherer.searchFile('/path/to/file', 'search(er){0,2}', { caseSensitive: true });\n  \n  console.log(results);\n})();\n```\n\n### `Searcherer.searchFileSync(filePath, dictionary[, options])`\n\nA synchronous version of the `Searcherer.searchFile` method.\n\n### `Searcherer([options])`\n\nCreates an instance of `Searcherer` using the `options` provided.\n\nThe `dictionary` option can be specified to initialize `Searcherer` with a single `Dictionary`. It can be either a\n`Dictionary` instance or one or more of search patterns from which a `Dictionary` instance can be created.\n\nWhile the static methods of `Searcherer` for searching work great, it's encouraged to create `Searcherer` instances when\ndealing with multiple dictionaries (collections of search patterns). Additionally, it's **highly recommended** that\n`Dictionary` instances are created when searching a large number of patterns and/or using the same patterns to search\nmany different strings/files. Doing so will increase performance as regular expressions compiled from the patterns are\ncached.\n\nThe following instance methods exist to mirror the static methods for searching:\n\n* `Searcherer#search(value[, options])`\n* `Searcherer#searchFile(filePath[, options])`\n* `Searcherer#searchFileSync(filePath[, options])`\n\nAdditionally, the following instance methods exist that allow dictionaries to be added to a `Searcherer` instance:\n\n* `Searcherer#addDictionary(dictionary)`\n* `Searcherer#addDictionaryFile(filePath)`\n* `Searcherer#addDictionaryFileSync(filePath)`\n\n#### Options\n\n| Option           | Description                                                           | Default      |\n| ---------------- | --------------------------------------------------------------------- | ------------ |\n| `dictionary`     | Initial `Dictionary` or the search pattern(s) to be used to create it | N/A          |\n| `dictionaryType` | `Dictionary` implementation whose instances are to be created         | `Dictionary` |\n\n#### Events\n\nEach of the search methods can emit the following events:\n\n| Event    | Description                                     |\n| -------- | ----------------------------------------------- |\n| `end`    | Fired once the search has completed             |\n| `result` | Fired immediately when a search result is found |\n| `search` | Fired immediately before the value is searched  |\n\n#### Examples\n\n``` javascript\nconst Searcherer = require('searcherer');\nconst { Dictionary } = Searcherer;\n\n(async() =\u003e {\n  const searcherer = new Searcher();\n  searcherer.addDictionary(new Dictionary({ name: 'foo', patterns: [ ... ] ));\n  searcherer.addDictionary(new Dictionary({ name: 'bar', patterns: [ ... ] ));\n  \n  const results = await searcherer.searchFile('/path/to/file', { caseSensitive: true });\n  \n  console.log(results);\n})();\n```\n\n## Bugs\n\nIf you have any problems with Searcherer or would like to see changes currently in development you can do so\n[here](https://github.com/NotNinja/searcherer/issues).\n\n## Contributors\n\nIf you want to contribute, you're a legend! Information on how you can do so can be found in\n[CONTRIBUTING.md](https://github.com/NotNinja/searcherer/blob/master/CONTRIBUTING.md). We want your suggestions and pull\nrequests!\n\nA list of Searcherer contributors can be found in\n[AUTHORS.md](https://github.com/NotNinja/searcherer/blob/master/AUTHORS.md).\n\n## License\n\nSee [LICENSE.md](https://github.com/NotNinja/searcherer/raw/master/LICENSE.md) for more information on our MIT license.\n\n[![Copyright !ninja](https://cdn.rawgit.com/NotNinja/branding/master/assets/copyright/base/not-ninja-copyright-186x25.png)](https://not.ninja)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotninja%2Fsearcherer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotninja%2Fsearcherer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotninja%2Fsearcherer/lists"}