{"id":17256151,"url":"https://github.com/jalal246/find-in","last_synced_at":"2025-04-14T05:42:31.130Z","repository":{"id":38011319,"uuid":"99424943","full_name":"jalal246/find-in","owner":"jalal246","description":"Yet another tool, written in JS for Searching Text in Files!","archived":false,"fork":false,"pushed_at":"2023-03-05T17:50:14.000Z","size":383,"stargazers_count":11,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T19:40:22.260Z","etag":null,"topics":["async","callback","chunk","filesystem","finder","fs","node-js","promise","regex","search","search-in-file","search-in-text","stream","text","text-processing"],"latest_commit_sha":null,"homepage":"https://jalal246.github.io/find-in/","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/jalal246.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-05T13:37:29.000Z","updated_at":"2023-08-10T11:37:08.000Z","dependencies_parsed_at":"2025-02-24T19:43:32.821Z","dependency_job_id":null,"html_url":"https://github.com/jalal246/find-in","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Ffind-in","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Ffind-in/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Ffind-in/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Ffind-in/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jalal246","download_url":"https://codeload.github.com/jalal246/find-in/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670616,"owners_count":21142932,"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":["async","callback","chunk","filesystem","finder","fs","node-js","promise","regex","search","search-in-file","search-in-text","stream","text","text-processing"],"created_at":"2024-10-15T07:13:44.276Z","updated_at":"2025-04-14T05:42:31.105Z","avatar_url":"https://github.com/jalal246.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# find-in\n\n\u003e Node text search in files\n\n```bash\nnpm install find-in\n```\n\n## How it works?\n\nIt creates read [stream](https://nodejs.org/api/stream.html) to read from the target file in chunks, matches the chunks using [match](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/match) method and returns an array of objects contains the final results.\n\n## API\n\n## find(options)\n\n`options` object contains:\n\n- `path: string` file path,\n- `request: array` array of [regex](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions) that will be matched in file\n- `encoding:? string` read stream encoding (default: `utf8`)\n- `join: string` number of chunk combined (default: 2), increasing the number will widen the matching chunk boundaries\n\nThe results is promise contains `report: array` An array of objects. Each element contains three keys:\n\n- `isFound: Boolean` search result\n- `reg: string` regex sent in request\n- `match: array` matching result. An array if there are results otherwise returns null. for more see [String.prototype.match()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)\n\n### Examples\n\n```js\nconst find = require(\"find-in\");\n\n// let's create some request to search for it in our file.\nconst req = [/old/g, /new/g];\n\nconst report = await find({ path: \"/path/to/fileName\", request: req });\n\n// \u003e report:\n//\n// [\n//   {\n//     isFound: true,\n//     reg: /old/g,\n//     match: [\"old\"], // the result of matching\n//   },\n//   {\n//     isFound: false, // not found so it wasn't changed\n//     reg: /new/g,\n//     match: null,\n//   },\n// ];\n```\n\nOr you can check a specific result as following.\n\n```js\nconst report = await find({\n  path: \"/path/to/fileName\",\n  request: [phrase0, phrase1, phrase2, phrase3],\n});\n\nif (report[2].isFound) {\n  console.log(\"found phrase2!\");\n  // do something\n} else {\n  console.log(\"phrase2 is not found!\");\n  // do something else\n}\n```\n\n## Tests\n\n```sh\nyarn test\n```\n\n### Related projects\n\n- [textics](https://github.com/jalal246/textics-stream) \u0026\n  [textics-stream](https://github.com/jalal246/textics) - counts lines, words, chars and spaces for a given string.\n\n- [replace-in](https://github.com/jalal246/replace-in) - Replace text in a given file.\n\n- [packageSorter](https://github.com/jalal246/packageSorter) - Sorting packages\n  for monorepos production.\n\n- [builderz](https://github.com/jalal246/builderz) - Building your project with zero config.\n\n- [corename](https://github.com/jalal246/corename) - Extracts package name.\n\n- [move-position](https://github.com/jalal246/move-position) - Moves element in\n  given array form index-A to index-B.\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/jalal246/find-in/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalal246%2Ffind-in","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjalal246%2Ffind-in","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalal246%2Ffind-in/lists"}