{"id":21586077,"url":"https://github.com/magiclen/node-fast-string-search","last_synced_at":"2025-04-10T20:20:35.171Z","repository":{"id":57233114,"uuid":"95085008","full_name":"magiclen/node-fast-string-search","owner":"magiclen","description":"Fast search substrings in a string by using N-API and boyer-moore-magiclen.","archived":false,"fork":false,"pushed_at":"2023-10-30T12:19:21.000Z","size":705,"stargazers_count":22,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T17:55:21.951Z","etag":null,"topics":["c","nodejs","string-search"],"latest_commit_sha":null,"homepage":"","language":"C","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/magiclen.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-06-22T07:01:54.000Z","updated_at":"2025-01-30T00:19:31.000Z","dependencies_parsed_at":"2024-06-19T05:35:45.668Z","dependency_job_id":null,"html_url":"https://github.com/magiclen/node-fast-string-search","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnode-fast-string-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnode-fast-string-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnode-fast-string-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnode-fast-string-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/node-fast-string-search/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248289836,"owners_count":21078921,"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":["c","nodejs","string-search"],"created_at":"2024-11-24T15:12:36.785Z","updated_at":"2025-04-10T20:20:35.147Z","avatar_url":"https://github.com/magiclen.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Fast String Search\n=================================\n\n[![CI](https://github.com/magiclen/node-fast-string-search/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/node-fast-string-search/actions/workflows/ci.yml)\n\nThis module can search substrings in a string by using N-API and boyer-moore-magiclen. The result of benchmark shows that this module is **10 times faster** than the `indexOf` function of a Node.js string.\n\n## Initialization\n\nImport this module by using `require` function.\n\n```javascript\nconst fss = require(\"fast-string-search\");\n```\n\n## Usage\n\n### indexOf\n\nFull text search in a string.\n\n```javascript\nconst a = fss.indexOf(\"coocoocoocoo\", \"oocoo\"); // [1, 4, 7]\n```\n\nYou can also set the offset of characters and the number of substrings you want to find.\n\n```javascript\nconst a = fss.indexOf(source, pattern, offset, limit);\n```\n\nThe default value of `offset` is `0`, and the default value of `limit` is `1000`.\n\n### indexOfSkip\n\nNormal text search in a string.\n\n```javascript\nconst a = fss.indexOfSkip(\"coocoocoocoo\", \"oocoo\"); // [1, 7]\n```\n\n### lastIndexOf\n\nFull text search from the end of a string.\n\n```javascript\nconst a = fss.lastIndexOf(\"coocoocoocoo\", \"oocoo\"); // [7, 4, 1]\n```\n\n### utf16IndexOf/utf16IndexOfSkip/utf16LastIndexOf\n\n```javascript\nconst a = fss.utf16IndexOf(Buffer.from(\"coocoocoocoo\", \"utf16le\"), Buffer.from(\"oocoo\", \"utf16le\")); // [1, 4, 7]\n```\n\n## Tests\n\nTo run the test suite, first install the dependencies, then run `npm test`:\n\n```bash\nnpm install\nnpm test\n```\n\n## Benchmark\n\nTo run the benchmark suite, first install the dependencies, then run `npm run benchmark`:\n\n```bash\nnpm install\nnpm run benchmark\n```\n\nHere is my result,\n\n```bash\nFull Text Search\n  - 87 milliseconds\n  ✓ natively search text(indexOf) (87ms)\n  - 7 milliseconds\n  ✓ Use FSS to search text\n\nNormal Text Search\n  - 35 milliseconds\n  ✓ natively search text(indexOf)\n  - 46 milliseconds\n  ✓ natively search text(RegExp) (46ms)\n  - 6 milliseconds\n  ✓ Use FSS to search text\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fnode-fast-string-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fnode-fast-string-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fnode-fast-string-search/lists"}