How to use @babel/helper-regex - 6 common examples

To help you get started, we’ve selected a few @babel/helper-regex 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 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');
				}
			}
		}
github babel / babel / packages / babel-plugin-transform-es2015-sticky-regex / src / index.js View on Github external
RegExpLiteral(path) {
        const { node } = path;
        if (!regex.is(node, "y")) return;

        path.replaceWith(
          t.newExpression(t.identifier("RegExp"), [
            t.stringLiteral(node.pattern),
            t.stringLiteral(node.flags),
          ]),
        );
      },
    },
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 babel / babel / packages / babel-plugin-transform-sticky-regex / src / index.js View on Github external
RegExpLiteral(path) {
        const { node } = path;
        if (!regex.is(node, "y")) return;

        path.replaceWith(
          t.newExpression(t.identifier("RegExp"), [
            t.stringLiteral(node.pattern),
            t.stringLiteral(node.flags),
          ]),
        );
      },
    },
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');
				}
			}
		}
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");
      },
    },

@babel/helper-regex

Helper function to check for literal RegEx

MIT
Latest version published 4 years ago

Package Health Score

85 / 100
Full package analysis

Popular @babel/helper-regex functions

Similar packages