Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
oniguruma-to-es
Advanced tools
This is an in-development Oniguruma to JavaScript RegExp transpiler that runs in any JavaScript environment. It gives you the ability to:
Compared to running the actual Oniguruma C library in JavaScript via WASM bindings (e.g. via vscode-oniguruma or node-oniguruma), this library is much lighter weight and its regexes run much faster.
Oniguruma-To-ES deeply understands all of the hundreds of large and small differences in Oniguruma and JavaScript regex syntax and behavior across multiple JavaScript version targets. It's obsessive about exactly following Oniguruma syntax rules and ensuring that the emulated features it supports have exactly the same behavior, even in extreme edge cases. A few uncommon features can't be perfectly emulated and allow rare differences, but if you don't want to allow this, you can disable the allowBestEffort
option to throw for such patterns (see details below).
These options are shared by functions compile
and toRegExp
.
allowBestEffort
Allows results that differ from Oniguruma in rare cases. If false
, throws if the pattern can't be emulated with identical behavior for the given target
.
Specifically, this option enables the following additional features, depending on target
:
ESNext
and earlier):
\X
using a close approximation of a Unicode extended grapheme cluster.\g<0>
and \g<name>
using a depth limit specified via option maxRecursionDepth
.ES2024
and earlier:
ES2018
:
[:graph:]
and [:print:]
using ASCII versions rather than the Unicode versions available for ES2024
and later. Other POSIX classes always use Unicode.Default: true
.
maxRecursionDepth
If null
, any use of recursion throws. If an integer between 2
and 100
(and allowBestEffort
is on), common recursion forms are supported and recurse up to the specified max depth.
Default: 6
.
optimize
Simplify the generated pattern when it doesn't change the meaning.
Default: true
.
target
Sets the JavaScript language version for generated patterns and flags. Later targets allow faster processing, simpler generated source, and support for additional Oniguruma features.
ES2018
: Uses JS flag u
.
ES2024
: Uses JS flag v
.
ESNext
: Uses JS flag v
and allows use of flag groups and duplicate group names.
Default: 'ES2024'
.
Oniguruma-To-ES fully supports mixed case-sensitivity (and handles the Unicode edge cases) regardless of JavaScript target. It also restricts Unicode properties to those supported by Oniguruma and the target JavaScript version.
Oniguruma-To-ES focuses on being lightweight to make it better for use in browsers. This is partly achieved by not including heavyweight Unicode character data, which imposes a couple of minor/rare restrictions:
ES2018
. Use target ES2024
or later if you need support for these Oniguruma features.\p{Lower}
) can't be used case-insensitively in patterns that contain other characters with a specific case that are used case-sensitively.
A\p{Lower}
, (?i:A\p{Lower})
, (?i:A)\p{Lower}
, (?i:A(?-i:\p{Lower}))
, and \w(?i:\p{Lower})
, but not A(?i:\p{Lower})
.js_regex transpiles Onigmo regexes to JavaScript (Onigmo is a fork of Oniguruma that has slightly different syntax/behavior). js_regex is written in Ruby and relies on Ruby's Onigmo parser, which means regexes must be pre-transpiled to use them in JavaScript. In contrast, Oniguruma-To-ES is written in JavaScript, so it can be used at runtime. js_regex also produces regexes with more edge cases that don't perfectly follow Oniguruma's behavior, in addition to the Oniguruma/Onigmo differences.
FAQs
Covert Oniguruma regexes to native JavaScript RegExp
The npm package oniguruma-to-es receives a total of 70 weekly downloads. As such, oniguruma-to-es popularity was classified as not popular.
We found that oniguruma-to-es demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.