How to use regexpu-core - 3 common examples

To help you get started, we’ve selected a few regexpu-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yyx990803 / buble / src / program / types / Literal.js View on Github external
}
		}

		if (this.regex) {
			const { pattern, flags } = this.regex;

			if (transforms.stickyRegExp && /y/.test(flags))
				throw new CompileError(
					'Regular expression sticky flag is not supported',
					this
				);
			if (transforms.unicodeRegExp && /u/.test(flags)) {
				code.overwrite(
					this.start,
					this.end,
					`/${rewritePattern(pattern, flags)}/${flags.replace('u', '')}`,
					{
						contentOnly: true
					}
				);
			}
		}
	}
}
github babel / babel / packages / babel-plugin-transform-es2015-unicode-regex / src / index.js View on Github external
RegExpLiteral({ node }) {
        if (!regex.is(node, "u")) return;
        node.pattern = rewritePattern(node.pattern, node.flags);
        regex.pullFlag(node, "u");
      },
    },
github mathiasbynens / babel-plugin-transform-unicode-property-regex / src / index.js View on Github external
RegExpLiteral(path, state) {
				const node = path.node;
				if (!regex.is(node, 'u')) {
					return;
				}
				const useUnicodeFlag = state.opts.useUnicodeFlag || false;
				node.pattern = rewritePattern(node.pattern, node.flags, {
					'unicodePropertyEscape': true,
					'useUnicodeFlag': useUnicodeFlag
				});
				if (!useUnicodeFlag) {
					regex.pullFlag(node, 'u');
				}
			}
		}

regexpu-core

regexpu’s core functionality (i.e. `rewritePattern(pattern, flag)`), capable of translating ES6 Unicode regular expressions to ES5.

MIT
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis

Popular regexpu-core functions