0.19.0 • Published 10 months ago
babel-plugin-melody v0.19.0
A babel plugin that converts string literals and template strings containing Melody syntax to regular expression syntax.
To mark a string for the plugin, add /*melody*/
before it.
Install
npm install --save-dev babel-plugin-melody
or
yarn add -D babel-plugin-melody
Usage
// .babelrc
{
"plugins": ["babel-plugin-melody"]
}
Example
Input
const regex = new RegExp(/*melody*/ `2 to 3 of "na";`);
const otherRegex = new RegExp(/*melody*/ '5 to 9 of "other";');
const rawRegex = /*melody*/ `
<start>;
"other";
<end>;
`;
const thirdRegex = new RegExp(rawRegex);
Output
const regex = new RegExp('(?:na){2,3}');
const otherRegex = new RegExp('(?:other){5,9}');
const rawRegex = '^other$';
const thirdRegex = new RegExp(rawRegex);
Known issues
- Interpolation within template strings is not currently supported
Links
0.19.0
10 months ago
0.18.1
2 years ago
0.17.0
2 years ago
0.18.0
2 years ago
0.13.23
2 years ago
0.13.21
2 years ago
0.13.20
2 years ago
0.13.18
2 years ago
0.13.17
2 years ago
0.13.16
2 years ago
0.13.15
2 years ago
0.13.14
2 years ago
0.13.13
2 years ago
0.13.12
2 years ago
0.13.11
2 years ago
0.13.10
2 years ago
0.13.9
2 years ago