{"id":16906039,"url":"https://github.com/chocobo1/bmhs","last_synced_at":"2026-05-21T05:36:39.189Z","repository":{"id":86429368,"uuid":"164691369","full_name":"Chocobo1/bmhs","owner":"Chocobo1","description":"Boyer–Moore–Horspool algorithm that works with JS Array \u0026 TypedArray","archived":false,"fork":false,"pushed_at":"2022-12-11T13:44:00.000Z","size":52,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-25T15:24:13.705Z","etag":null,"topics":["boyer-moore-horspool","javascript-library","string-search"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chocobo1.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":"2019-01-08T16:38:27.000Z","updated_at":"2022-12-28T08:38:09.000Z","dependencies_parsed_at":"2023-07-13T16:31:08.588Z","dependency_job_id":null,"html_url":"https://github.com/Chocobo1/bmhs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chocobo1%2Fbmhs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chocobo1%2Fbmhs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chocobo1%2Fbmhs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chocobo1%2Fbmhs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chocobo1","download_url":"https://codeload.github.com/Chocobo1/bmhs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244647927,"owners_count":20487167,"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":["boyer-moore-horspool","javascript-library","string-search"],"created_at":"2024-10-13T18:40:38.883Z","updated_at":"2026-05-21T05:36:34.165Z","avatar_url":"https://github.com/Chocobo1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Boyer–Moore–Horspool Search\n\nAn naive implementation of [Boyer–Moore–Horspool algorithm][wikipedia_link] that works with [Array][mdn_array_link] \u0026 [TypedArray][mdn_typed_array_link]\n\n[wikipedia_link]: https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm\n[mdn_array_link]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n[mdn_typed_array_link]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\n\n### Installation\n```shell\nnpm install git+https://github.com/Chocobo1/bmhs.git\n```\n\n### Usage example\n```javascript\nconst Bmh = require('bmhs');  // import this module, CommonJS style\n//import * as Bmh from 'bmhs';  // import this module, ES module style\n\n// working with TypedArray\n{\n    const pattern = Uint32Array.from([0xFFFF, 0x3000]);\n    const corpus = Uint32Array.from([0xFFFF, 0xFFFF, 0x3000, 0x1000]);\n\n    // setup `bmh` for later reuse\n    const bmh = Bmh.BoyerMooreHorspool(pattern);\n    // returns the first index of the exact match in `corpus`; -1 if not found\n    const idx = bmh.match(corpus);\n    if (idx !== 1)\n        throw (new Error('Please file an issue'));\n}\n\n// also working with String\n{\n    const pattern = \"pattern\";\n    const corpus = \"some pattern !@#$%\";\n\n    const bmh = Bmh.BoyerMooreHorspool(pattern);\n    const idx = bmh.match(corpus);\n    if (idx !== corpus.indexOf(pattern))\n        throw (new Error('Please file an issue'));\n}\n\n// you can specify offset!\n{\n    const pattern = \"123\";\n    const corpus = \"123abc123\";\n    const corpusOffset = 1;\n\n    const idx = Bmh.BoyerMooreHorspool(pattern).match(corpus, corpusOffset);\n    if (idx !== corpus.indexOf(pattern, corpusOffset))\n        throw (new Error('Please file an issue'));\n}\n```\n\n### Run tests\n```shell\nnpm install -D  # install dev dependencies\nnpm test        # run tests\n```\n\n### References\n* https://www.inf.hs-flensburg.de/lang/algorithmen/pattern/horsen.htm\n* https://computing.dcu.ie/~humphrys/Notes/String/bm.html\n\n### See also\nYou might be interested to [Knuth–Morris–Pratt algorithm][kmp_link]\n\n[kmp_link]: https://github.com/Chocobo1/kmps\n\n### License\nSee [LICENSE](./LICENSE) file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocobo1%2Fbmhs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchocobo1%2Fbmhs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchocobo1%2Fbmhs/lists"}