https://github.com/blackglory/aho-corasick
🌿 A simple Node.js wrapper for Rust's native implementation.
https://github.com/blackglory/aho-corasick
library native nodejs npm-package rust
Last synced: 10 months ago
JSON representation
🌿 A simple Node.js wrapper for Rust's native implementation.
- Host: GitHub
- URL: https://github.com/blackglory/aho-corasick
- Owner: BlackGlory
- License: mit
- Created: 2021-03-29T16:38:23.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T17:34:10.000Z (over 2 years ago)
- Last Synced: 2025-01-01T17:17:46.804Z (over 1 year ago)
- Topics: library, native, nodejs, npm-package, rust
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@blackglory/aho-corasick
- Size: 2.85 MB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# aho-corasick
A simple Node.js wrapper for [Rust's daachorse].
It's faster than [the fastest pure JS implementation] I know of,
and it eats less memory.
[Rust's daachorse]: https://crates.io/crates/daachorse
[the fastest pure JS implementation]: https://www.npmjs.com/package/fastscan
## Install
```sh
npm install --save @blackglory/aho-corasick
# or
yarn add @blackglory/aho-corasick
```
## API
```ts
class AhoCorasick {
constructor(
patterns: string[]
, options: { caseSensitive: boolean }
)
isMatch(text: string): boolean
findAll(text: string): string[]
}
```
## Benchmark
The patterns come from the title of the Chinese Wikipedia.
The samples come from the text of the Chinese Wikipedia.
| | Compilation | Matching |
|------------------|---------------|---------------|
| fastscan | 2351 op/s | 16.8 op/s |
| **aho-corasick** | 2348 op/s | **63.5 op/s** |
The results of the benchmark are relative values,
which will change according to different patterns and samples.