Skip to content

Oniguruma regex library on the web using WebAssembly

License

Notifications You must be signed in to change notification settings

zikaari/onigasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Sep 22, 2020
82c56c3 · Sep 22, 2020

History

73 Commits
Jun 25, 2018
Jun 25, 2018
Nov 13, 2019
Nov 11, 2019
Nov 13, 2019
Nov 13, 2019
Nov 13, 2019
Jul 9, 2018
May 21, 2018
Feb 20, 2018
Jun 27, 2018
Jun 25, 2018
Sep 22, 2020
Sep 22, 2020
May 21, 2018
Nov 3, 2018

Repository files navigation

Onigasm (OnigurumaASM)

WebAssembly port of Oniguruma regex library.

Usage/API/Behaviour 1:1 with node-oniguruma port, tests are literally imported from node-oniguruma repository for maximum compliance.

Of course, unlike node-oniguruma, this library can't hook into roots of V8 and is therefore 2 times* slower than the former.

Instructions for porting your app to web

Install

npm i onigasm

Light it up

WASM must be loaded before you use any other feature like OnigRegExp or OnigScanner

// index.js (entry point)

import { loadWASM } from 'onigasm'
import App from './App'

(async () => {
    await loadWASM('path/to/onigasm.wasm') // You can also pass ArrayBuffer of onigasm.wasm file
    App.start()
})()

// `onigasm.wasm` file will be available at `onigasm/lib/onigasm.wasm` in `node_modules` of your project directory

Once loaded onigasm is a drop-in replacement for oniguruma

- import { OnigRegExp } from 'oniguruma'
+ import { OnigRegExp } from 'onigasm'

That's it!

* Tested under laboratory conditions using benchmark.js


License

onigasm is licensed under MIT License. See LICENSE in the root of this project for more info.

Contributors/Maintainers