https://github.com/glennsl/bs-revamp
A safe and functional API for JavaScript regexes
https://github.com/glennsl/bs-revamp
Last synced: 10 months ago
JSON representation
A safe and functional API for JavaScript regexes
- Host: GitHub
- URL: https://github.com/glennsl/bs-revamp
- Owner: glennsl
- License: mit
- Created: 2017-08-21T18:07:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T16:29:49.000Z (over 1 year ago)
- Last Synced: 2025-03-16T19:19:12.331Z (10 months ago)
- Language: JavaScript
- Size: 720 KB
- Stars: 12
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bs-re:vamp
An experimental safe and functional API for JavaScript regexes
[](https://npmjs.org/@glennsl/bs-revamp)
[](https://travis-ci.org/glennsl/bs-revamp)
[](https://coveralls.io/github/glennsl/bs-revamp?branch=master)
[](https://github.com/glennsl/bs-revamp/network/dependencies)
[](https://github.com/glennsl/bs-revamp/issues)
[](https://github.com/glennsl/bs-revamp/commits/master)
[](https://github.com/glennsl/bs-revamp/blob/master/lib/js/src/Revamp.js)
## Example
```reason
/*
* Dasherize camelCased identifiers inside string literals
*/
let code = {|
let borderLeftColor = "borderLeftColor";
let borderRightColor = "borderRightColor";
|};
code |> Revamp.replace({|"([^"]+)"|}, /* Matches the content of string literals */
Revamp.replace("[A-Z]", letter => /* Matches uppercase letters */
"-" ++ letter |> Js.String.toLowerCase)) /* Convert to lower case and prefix with a dash */
|> Js.log;
/* Outputs:
let borderLeftColor = "border-left-color";
let borderRightColor = "border-right-color";
*/
```
## Installation
```sh
npm install --save @glennsl/bs-revamp
```
Then add `@glennsl/bs-revamp` to `bs-dependencies` in your `bsconfig.json`:
```js
{
...
"bs-dependencies": ["@glennsl/bs-revamp"]
}
```
## Goals
- A sane, safe API
- Low performance overhead (secondary)
## Non-goals
- Full feature parity
## Documentation
For the moment, please see the interface file, [Revamp.rei](https://github.com/glennsl/bs-revamp/blob/master/src/Revamp.rei).
## Changes
### 0.2.0
- [BREAKING] Removed `Match.matches`, deprecated in 0.1.0, due to being unsound
### 0.1.0
- Changed type of `captures` from `Sequence.t(array(string))` to `Sequence.t(list(option(string)))` because the former was unsound.
- Added `Match.match` and `Match.captures`
- Deprecated `Match.matches` due to being unsound