https://github.com/redcmd/oniguruma-parser-cjs
CommonJS wrapper for oniguruma-parser
https://github.com/redcmd/oniguruma-parser-cjs
commonjs oniguruma
Last synced: 4 months ago
JSON representation
CommonJS wrapper for oniguruma-parser
- Host: GitHub
- URL: https://github.com/redcmd/oniguruma-parser-cjs
- Owner: RedCMD
- License: mit
- Created: 2025-05-04T11:19:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-04T11:19:54.000Z (about 1 year ago)
- Last Synced: 2025-09-17T22:13:53.117Z (9 months ago)
- Topics: commonjs, oniguruma
- Language: TypeScript
- Homepage: https://github.com/slevithan/oniguruma-parser
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oniguruma-parser-cjs
CommonJS wrapper for [oniguruma-parser](https://github.com/slevithan/oniguruma-parser).
## Installation
```sh
npm install oniguruma-parser-cjs
```
## Usage
```js
// CommonJS
const { toOnigurumaAst } = require('oniguruma-parser-cjs');
const ast = toOnigurumaAst('A.*');
console.log(ast);
// Optimizer
const { optimize } = require('oniguruma-parser-cjs/optimizer');
const optimized = optimize('[aa]', {
rules: {
// `vscode-oniguruma` enables this Oniguruma option by default
captureGroup: true,
allowOrphanBackrefs: true,
},
}).pattern;
console.log(optimized); // a
```
## Development
### Setup
```sh
# Install dependencies
pnpm install
```
### Building and Testing
```sh
# Clean build artifacts
pnpm clean
# Build the package
pnpm build
# Run tests
pnpm test
# Development workflow (clean, build, test)
pnpm dev
```
## Why
The original [oniguruma-parser](https://github.com/slevithan/oniguruma-parser) package is ESM-only, which can cause compatibility issues in CommonJS projects. This package provides a pre-built CommonJS version that can be used in any Node.js environment without the need for special configuration.
## License
[MIT](/LICENSE)