How to use the regexp-tree.compatTranspile function in regexp-tree

To help you get started, we’ve selected a few regexp-tree 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 DmitrySoshnikov / babel-plugin-transform-modern-regexp / index.js View on Github external
function getTranslatedData(regexp, state) {
  let whitelist = undefined;

  if (Array.isArray(state.opts.features) && state.opts.features.length > 0) {
    whitelist = state.opts.features;
  }

  const compat = regexpTree.compatTranspile(regexp, whitelist);

  return {
    pattern: compat.getSource(),
    flags: compat.getFlags(),
  };
}