Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

onigasm

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onigasm

WebAssembly port of Oniguruma regex library


Version published
Weekly downloads
26K
increased by17.9%
Maintainers
1
Weekly downloads
 
Created
Source

Onigasm (OnigurumaASM)

WebAssembly port of Oniguruma regex library.

Usage/API/Behaviour 100% same as 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 latter.

But don't loose faith! Searching for a string in a file* with 5839708 characters it only takes about ~260ms to process. Not bad if you ask me ;P

* File was taken from Microsoft/TypeScript/lib/typescriptServices.js

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()
})()

Once loaded onigasm is a drop-in replacement for oniguruma

// app.js (rest of the app)

/** replace this */ import { OnigRegExp } from 'oniguruma'
/** with this   */  import { OnigRegExp } from 'onigasm'

That's it!

To do

  • Pass node-oniguruma tests
  • Code cleanup wherever possible
  • Optimizations wherever possible
  • Improve internal and public documentation

Keywords

FAQs

Package last updated on 20 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc