How to use the ret.types.GROUP function in ret

To help you get started, we’ve selected a few ret 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 fent / randexp.js / lib / util.js View on Github external
exports.preprocess = function(tokens) {
  var good = [];

  // Traverse tokens in reverse so that tokens in front, which will
  // be used to compare `followedBy` and `notFollowedBy` groups,
  // are already processed.
  for (var i = tokens.length - 1; i >= 0; i--) {
    var token = tokens[i];
    if (token.type === types.GROUP || token.type === types.ROOT) {
      if (token.followedBy || token.notFollowedBy) {
        if (token.options) {
          token.options = token.options.map(exports.preprocess);
          good = [{
            type: types.GROUP,
            options: token.options.map(function(stack) {
              return addTokenList(stack, good, !!token.followedBy);
            }),
          }];
        } else if (token.stack) {
          token.stack = exports.preprocess(token.stack);
          good = addTokenList(token.stack, good, !!token.followedBy);
        }
      } else {
        good.unshift(exports.preprocessGroup(token));
      }

    } else {
      good.unshift(token);
    }
  }

ret

Tokenizes a string that represents a regular expression.

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis