{"id":16834663,"url":"https://github.com/mscdex/streamsearch","last_synced_at":"2025-04-04T15:10:34.374Z","repository":{"id":5897206,"uuid":"7115691","full_name":"mscdex/streamsearch","owner":"mscdex","description":"Streaming Boyer-Moore-Horspool searching for node.js","archived":false,"fork":false,"pushed_at":"2023-10-16T13:35:05.000Z","size":25,"stargazers_count":71,"open_issues_count":1,"forks_count":18,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-02T01:05:02.235Z","etag":null,"topics":[],"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/mscdex.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":"2012-12-11T17:01:03.000Z","updated_at":"2025-01-29T01:44:27.000Z","dependencies_parsed_at":"2024-09-16T21:31:43.019Z","dependency_job_id":null,"html_url":"https://github.com/mscdex/streamsearch","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"937d55fe80a988c18eb4e9a7b5b2db79bcfa25eb"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fstreamsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fstreamsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fstreamsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fstreamsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscdex","download_url":"https://codeload.github.com/mscdex/streamsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247043337,"owners_count":20874086,"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":[],"created_at":"2024-10-13T12:07:17.098Z","updated_at":"2025-04-04T15:10:34.357Z","avatar_url":"https://github.com/mscdex.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"Description\n===========\n\nstreamsearch is a module for [node.js](http://nodejs.org/) that allows searching a stream using the Boyer-Moore-Horspool algorithm.\n\nThis module is based heavily on the Streaming Boyer-Moore-Horspool C++ implementation by Hongli Lai [here](https://github.com/FooBarWidget/boyer-moore-horspool).\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v10.0.0 or newer\n\n\nInstallation\n============\n\n    npm install streamsearch\n\nExample\n=======\n\n```js\n  const { inspect } = require('util');\n\n  const StreamSearch = require('streamsearch');\n\n  const needle = Buffer.from('\\r\\n');\n  const ss = new StreamSearch(needle, (isMatch, data, start, end) =\u003e {\n    if (data)\n      console.log('data: ' + inspect(data.toString('latin1', start, end)));\n    if (isMatch)\n      console.log('match!');\n  });\n\n  const chunks = [\n    'foo',\n    ' bar',\n    '\\r',\n    '\\n',\n    'baz, hello\\r',\n    '\\n world.',\n    '\\r\\n Node.JS rules!!\\r\\n\\r\\n',\n  ];\n  for (const chunk of chunks)\n    ss.push(Buffer.from(chunk));\n\n  // output:\n  //\n  // data: 'foo'\n  // data: ' bar'\n  // match!\n  // data: 'baz, hello'\n  // match!\n  // data: ' world.'\n  // match!\n  // data: ' Node.JS rules!!'\n  // match!\n  // data: ''\n  // match!\n```\n\n\nAPI\n===\n\nProperties\n----------\n\n* **maxMatches** - \u003c _integer_ \u003e - The maximum number of matches. Defaults to `Infinity`.\n\n* **matches** - \u003c _integer_ \u003e - The current match count.\n\n\nFunctions\n---------\n\n* **(constructor)**(\u003c _mixed_ \u003eneedle, \u003c _function_ \u003ecallback) - Creates and returns a new instance for searching for a _Buffer_ or _string_ `needle`. `callback` is called any time there is non-matching data and/or there is a needle match. `callback` will be called with the following arguments:\n\n  1. `isMatch` - _boolean_ - Indicates whether a match has been found\n\n  2. `data` - _mixed_ - If set, this contains data that did not match the needle.\n\n  3. `start` - _integer_ - The index in `data` where the non-matching data begins (inclusive).\n\n  4. `end` - _integer_ - The index in `data` where the non-matching data ends (exclusive).\n\n  5. `isSafeData` - _boolean_ - Indicates if it is safe to store a reference to `data` (e.g. as-is or via `data.slice()`) or not, as in some cases `data` may point to a Buffer whose contents change over time.\n\n* **destroy**() - _(void)_ - Emits any last remaining unmatched data that may still be buffered and then resets internal state.\n\n* **push**(\u003c _Buffer_ \u003echunk) - _integer_ - Processes `chunk`, searching for a match. The return value is the last processed index in `chunk` + 1.\n\n* **reset**() - _(void)_ - Resets internal state. Useful for when you wish to start searching a new/different stream for example.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fstreamsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscdex%2Fstreamsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fstreamsearch/lists"}