lightfold
Version:
lightweight scaffolding and archiving utility CLI.
1,297 lines (1,046 loc) • 340 kB
JavaScript
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.XRegExp = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
/*!
* XRegExp.build 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2012-present MIT License
*/
var _default = function _default(XRegExp) {
var REGEX_DATA = 'xregexp';
var subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g;
var parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g', {
conjunction: 'or'
});
/**
* Strips a leading `^` and trailing unescaped `$`, if both are present.
*
* @private
* @param {String} pattern Pattern to process.
* @returns {String} Pattern with edge anchors removed.
*/
function deanchor(pattern) {
// Allow any number of empty noncapturing groups before/after anchors, because regexes
// built/generated by XRegExp sometimes include them
var leadingAnchor = /^(?:\(\?:\))*\^/;
var trailingAnchor = /\$(?:\(\?:\))*$/;
if (leadingAnchor.test(pattern) && trailingAnchor.test(pattern) && // Ensure that the trailing `$` isn't escaped
trailingAnchor.test(pattern.replace(/\\[\s\S]/g, ''))) {
return pattern.replace(leadingAnchor, '').replace(trailingAnchor, '');
}
return pattern;
}
/**
* Converts the provided value to an XRegExp. Native RegExp flags are not preserved.
*
* @private
* @param {String|RegExp} value Value to convert.
* @param {Boolean} [addFlagX] Whether to apply the `x` flag in cases when `value` is not
* already a regex generated by XRegExp
* @returns {RegExp} XRegExp object with XRegExp syntax applied.
*/
function asXRegExp(value, addFlagX) {
var flags = addFlagX ? 'x' : '';
return XRegExp.isRegExp(value) ? value[REGEX_DATA] && value[REGEX_DATA].captureNames ? // Don't recompile, to preserve capture names
value : // Recompile as XRegExp
XRegExp(value.source, flags) : // Compile string as XRegExp
XRegExp(value, flags);
}
function interpolate(substitution) {
return substitution instanceof RegExp ? substitution : XRegExp.escape(substitution);
}
function reduceToSubpatternsObject(subpatterns, interpolated, subpatternIndex) {
subpatterns["subpattern".concat(subpatternIndex)] = interpolated;
return subpatterns;
}
function embedSubpatternAfter(raw, subpatternIndex, rawLiterals) {
var hasSubpattern = subpatternIndex < rawLiterals.length - 1;
return raw + (hasSubpattern ? "{{subpattern".concat(subpatternIndex, "}}") : '');
}
/**
* Provides tagged template literals that create regexes with XRegExp syntax and flags. The
* provided pattern is handled as a raw string, so backslashes don't need to be escaped.
*
* Interpolation of strings and regexes shares the features of `XRegExp.build`. Interpolated
* patterns are treated as atomic units when quantified, interpolated strings have their special
* characters escaped, a leading `^` and trailing unescaped `$` are stripped from interpolated
* regexes if both are present, and any backreferences within an interpolated regex are
* rewritten to work within the overall pattern.
*
* @memberOf XRegExp
* @param {String} [flags] Any combination of XRegExp flags.
* @returns {Function} Handler for template literals that construct regexes with XRegExp syntax.
* @example
*
* const h12 = /1[0-2]|0?[1-9]/;
* const h24 = /2[0-3]|[01][0-9]/;
* const hours = XRegExp.tag('x')`${h12} : | ${h24}`;
* const minutes = /^[0-5][0-9]$/;
* // Note that explicitly naming the 'minutes' group is required for named backreferences
* const time = XRegExp.tag('x')`^ ${hours} (?<minutes>${minutes}) $`;
* time.test('10:59'); // -> true
* XRegExp.exec('10:59', time).minutes; // -> '59'
*/
XRegExp.tag = function (flags) {
return function (literals) {
var _context, _context2;
for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
substitutions[_key - 1] = arguments[_key];
}
var subpatterns = (0, _reduce.default)(_context = (0, _map.default)(substitutions).call(substitutions, interpolate)).call(_context, reduceToSubpatternsObject, {});
var pattern = (0, _map.default)(_context2 = literals.raw).call(_context2, embedSubpatternAfter).join('');
return XRegExp.build(pattern, subpatterns, flags);
};
};
/**
* Builds regexes using named subpatterns, for readability and pattern reuse. Backreferences in
* the outer pattern and provided subpatterns are automatically renumbered to work correctly.
* Native flags used by provided subpatterns are ignored in favor of the `flags` argument.
*
* @memberOf XRegExp
* @param {String} pattern XRegExp pattern using `{{name}}` for embedded subpatterns. Allows
* `({{name}})` as shorthand for `(?<name>{{name}})`. Patterns cannot be embedded within
* character classes.
* @param {Object} subs Lookup object for named subpatterns. Values can be strings or regexes. A
* leading `^` and trailing unescaped `$` are stripped from subpatterns, if both are present.
* @param {String} [flags] Any combination of XRegExp flags.
* @returns {RegExp} Regex with interpolated subpatterns.
* @example
*
* const time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
* hours: XRegExp.build('{{h12}} : | {{h24}}', {
* h12: /1[0-2]|0?[1-9]/,
* h24: /2[0-3]|[01][0-9]/
* }, 'x'),
* minutes: /^[0-5][0-9]$/
* });
* time.test('10:59'); // -> true
* XRegExp.exec('10:59', time).minutes; // -> '59'
*/
XRegExp.build = function (pattern, subs, flags) {
flags = flags || ''; // Used with `asXRegExp` calls for `pattern` and subpatterns in `subs`, to work around how
// some browsers convert `RegExp('\n')` to a regex that contains the literal characters `\`
// and `n`. See more details at <https://github.com/slevithan/xregexp/pull/163>.
var addFlagX = (0, _includes.default)(flags).call(flags, 'x');
var inlineFlags = /^\(\?([\w$]+)\)/.exec(pattern); // Add flags within a leading mode modifier to the overall pattern's flags
if (inlineFlags) {
flags = XRegExp._clipDuplicates(flags + inlineFlags[1]);
}
var data = {};
for (var p in subs) {
if (subs.hasOwnProperty(p)) {
// Passing to XRegExp enables extended syntax and ensures independent validity,
// lest an unescaped `(`, `)`, `[`, or trailing `\` breaks the `(?:)` wrapper. For
// subpatterns provided as native regexes, it dies on octals and adds the property
// used to hold extended regex instance data, for simplicity.
var sub = asXRegExp(subs[p], addFlagX);
data[p] = {
// Deanchoring allows embedding independently useful anchored regexes. If you
// really need to keep your anchors, double them (i.e., `^^...$$`).
pattern: deanchor(sub.source),
names: sub[REGEX_DATA].captureNames || []
};
}
} // Passing to XRegExp dies on octals and ensures the outer pattern is independently valid;
// helps keep this simple. Named captures will be put back.
var patternAsRegex = asXRegExp(pattern, addFlagX); // 'Caps' is short for 'captures'
var numCaps = 0;
var numPriorCaps;
var numOuterCaps = 0;
var outerCapsMap = [0];
var outerCapNames = patternAsRegex[REGEX_DATA].captureNames || [];
var output = patternAsRegex.source.replace(parts, function ($0, $1, $2, $3, $4) {
var subName = $1 || $2;
var capName;
var intro;
var localCapIndex; // Named subpattern
if (subName) {
var _context3;
if (!data.hasOwnProperty(subName)) {
throw new ReferenceError("Undefined property ".concat($0));
} // Named subpattern was wrapped in a capturing group
if ($1) {
capName = outerCapNames[numOuterCaps];
outerCapsMap[++numOuterCaps] = ++numCaps; // If it's a named group, preserve the name. Otherwise, use the subpattern name
// as the capture name
intro = "(?<".concat(capName || subName, ">");
} else {
intro = '(?:';
}
numPriorCaps = numCaps;
var rewrittenSubpattern = data[subName].pattern.replace(subParts, function (match, paren, backref) {
// Capturing group
if (paren) {
capName = data[subName].names[numCaps - numPriorCaps];
++numCaps; // If the current capture has a name, preserve the name
if (capName) {
return "(?<".concat(capName, ">");
} // Backreference
} else if (backref) {
localCapIndex = +backref - 1; // Rewrite the backreference
return data[subName].names[localCapIndex] ? // Need to preserve the backreference name in case using flag `n`
"\\k<".concat(data[subName].names[localCapIndex], ">") : "\\".concat(+backref + numPriorCaps);
}
return match;
});
return (0, _concat.default)(_context3 = "".concat(intro)).call(_context3, rewrittenSubpattern, ")");
} // Capturing group
if ($3) {
capName = outerCapNames[numOuterCaps];
outerCapsMap[++numOuterCaps] = ++numCaps; // If the current capture has a name, preserve the name
if (capName) {
return "(?<".concat(capName, ">");
} // Backreference
} else if ($4) {
localCapIndex = +$4 - 1; // Rewrite the backreference
return outerCapNames[localCapIndex] ? // Need to preserve the backreference name in case using flag `n`
"\\k<".concat(outerCapNames[localCapIndex], ">") : "\\".concat(outerCapsMap[+$4]);
}
return $0;
});
return XRegExp(output, flags);
};
};
exports.default = _default;
module.exports = exports["default"];
},{"@babel/runtime-corejs3/core-js-stable/instance/concat":10,"@babel/runtime-corejs3/core-js-stable/instance/includes":13,"@babel/runtime-corejs3/core-js-stable/instance/map":15,"@babel/runtime-corejs3/core-js-stable/instance/reduce":16,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],2:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
/*!
* XRegExp.matchRecursive 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2009-present MIT License
*/
var _default = function _default(XRegExp) {
/**
* Returns a match detail object composed of the provided values.
*
* @private
*/
function row(name, value, start, end) {
return {
name: name,
value: value,
start: start,
end: end
};
}
/**
* Returns an array of match strings between outermost left and right delimiters, or an array of
* objects with detailed match parts and position data. An error is thrown if delimiters are
* unbalanced within the data.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {String} left Left delimiter as an XRegExp pattern.
* @param {String} right Right delimiter as an XRegExp pattern.
* @param {String} [flags] Any native or XRegExp flags, used for the left and right delimiters.
* @param {Object} [options] Lets you specify `valueNames` and `escapeChar` options.
* @returns {Array} Array of matches, or an empty array.
* @example
*
* // Basic usage
* let str = '(t((e))s)t()(ing)';
* XRegExp.matchRecursive(str, '\\(', '\\)', 'g');
* // -> ['t((e))s', '', 'ing']
*
* // Extended information mode with valueNames
* str = 'Here is <div> <div>an</div></div> example';
* XRegExp.matchRecursive(str, '<div\\s*>', '</div>', 'gi', {
* valueNames: ['between', 'left', 'match', 'right']
* });
* // -> [
* // {name: 'between', value: 'Here is ', start: 0, end: 8},
* // {name: 'left', value: '<div>', start: 8, end: 13},
* // {name: 'match', value: ' <div>an</div>', start: 13, end: 27},
* // {name: 'right', value: '</div>', start: 27, end: 33},
* // {name: 'between', value: ' example', start: 33, end: 41}
* // ]
*
* // Omitting unneeded parts with null valueNames, and using escapeChar
* str = '...{1}.\\{{function(x,y){return {y:x}}}';
* XRegExp.matchRecursive(str, '{', '}', 'g', {
* valueNames: ['literal', null, 'value', null],
* escapeChar: '\\'
* });
* // -> [
* // {name: 'literal', value: '...', start: 0, end: 3},
* // {name: 'value', value: '1', start: 4, end: 5},
* // {name: 'literal', value: '.\\{', start: 6, end: 9},
* // {name: 'value', value: 'function(x,y){return {y:x}}', start: 10, end: 37}
* // ]
*
* // Sticky mode via flag y
* str = '<1><<<2>>><3>4<5>';
* XRegExp.matchRecursive(str, '<', '>', 'gy');
* // -> ['1', '<<2>>', '3']
*/
XRegExp.matchRecursive = function (str, left, right, flags, options) {
flags = flags || '';
options = options || {};
var global = (0, _includes.default)(flags).call(flags, 'g');
var sticky = (0, _includes.default)(flags).call(flags, 'y'); // Flag `y` is controlled internally
var basicFlags = flags.replace(/y/g, '');
var _options = options,
escapeChar = _options.escapeChar;
var vN = options.valueNames;
var output = [];
var openTokens = 0;
var delimStart = 0;
var delimEnd = 0;
var lastOuterEnd = 0;
var outerStart;
var innerStart;
var leftMatch;
var rightMatch;
var esc;
left = XRegExp(left, basicFlags);
right = XRegExp(right, basicFlags);
if (escapeChar) {
var _context, _context2;
if (escapeChar.length > 1) {
throw new Error('Cannot use more than one escape character');
}
escapeChar = XRegExp.escape(escapeChar); // Example of concatenated `esc` regex:
// `escapeChar`: '%'
// `left`: '<'
// `right`: '>'
// Regex is: /(?:%[\S\s]|(?:(?!<|>)[^%])+)+/
esc = new RegExp((0, _concat.default)(_context = (0, _concat.default)(_context2 = "(?:".concat(escapeChar, "[\\S\\s]|(?:(?!")).call(_context2, // Using `XRegExp.union` safely rewrites backreferences in `left` and `right`.
// Intentionally not passing `basicFlags` to `XRegExp.union` since any syntax
// transformation resulting from those flags was already applied to `left` and
// `right` when they were passed through the XRegExp constructor above.
XRegExp.union([left, right], '', {
conjunction: 'or'
}).source, ")[^")).call(_context, escapeChar, "])+)+"), // Flags `gy` not needed here
flags.replace(/[^imu]+/g, ''));
}
while (true) {
// If using an escape character, advance to the delimiter's next starting position,
// skipping any escaped characters in between
if (escapeChar) {
delimEnd += (XRegExp.exec(str, esc, delimEnd, 'sticky') || [''])[0].length;
}
leftMatch = XRegExp.exec(str, left, delimEnd);
rightMatch = XRegExp.exec(str, right, delimEnd); // Keep the leftmost match only
if (leftMatch && rightMatch) {
if (leftMatch.index <= rightMatch.index) {
rightMatch = null;
} else {
leftMatch = null;
}
} // Paths (LM: leftMatch, RM: rightMatch, OT: openTokens):
// LM | RM | OT | Result
// 1 | 0 | 1 | loop
// 1 | 0 | 0 | loop
// 0 | 1 | 1 | loop
// 0 | 1 | 0 | throw
// 0 | 0 | 1 | throw
// 0 | 0 | 0 | break
// The paths above don't include the sticky mode special case. The loop ends after the
// first completed match if not `global`.
if (leftMatch || rightMatch) {
delimStart = (leftMatch || rightMatch).index;
delimEnd = delimStart + (leftMatch || rightMatch)[0].length;
} else if (!openTokens) {
break;
}
if (sticky && !openTokens && delimStart > lastOuterEnd) {
break;
}
if (leftMatch) {
if (!openTokens) {
outerStart = delimStart;
innerStart = delimEnd;
}
++openTokens;
} else if (rightMatch && openTokens) {
if (! --openTokens) {
if (vN) {
if (vN[0] && outerStart > lastOuterEnd) {
output.push(row(vN[0], (0, _slice.default)(str).call(str, lastOuterEnd, outerStart), lastOuterEnd, outerStart));
}
if (vN[1]) {
output.push(row(vN[1], (0, _slice.default)(str).call(str, outerStart, innerStart), outerStart, innerStart));
}
if (vN[2]) {
output.push(row(vN[2], (0, _slice.default)(str).call(str, innerStart, delimStart), innerStart, delimStart));
}
if (vN[3]) {
output.push(row(vN[3], (0, _slice.default)(str).call(str, delimStart, delimEnd), delimStart, delimEnd));
}
} else {
output.push((0, _slice.default)(str).call(str, innerStart, delimStart));
}
lastOuterEnd = delimEnd;
if (!global) {
break;
}
}
} else {
throw new Error('Unbalanced delimiter found in string');
} // If the delimiter matched an empty string, avoid an infinite loop
if (delimStart === delimEnd) {
++delimEnd;
}
}
if (global && !sticky && vN && vN[0] && str.length > lastOuterEnd) {
output.push(row(vN[0], (0, _slice.default)(str).call(str, lastOuterEnd), lastOuterEnd, str.length));
}
return output;
};
};
exports.default = _default;
module.exports = exports["default"];
},{"@babel/runtime-corejs3/core-js-stable/instance/concat":10,"@babel/runtime-corejs3/core-js-stable/instance/includes":13,"@babel/runtime-corejs3/core-js-stable/instance/slice":17,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],3:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _getIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator"));
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
/*!
* XRegExp Unicode Base 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2008-present MIT License
*/
var _default = function _default(XRegExp) {
/**
* Adds base support for Unicode matching:
* - Adds syntax `\p{..}` for matching Unicode tokens. Tokens can be inverted using `\P{..}` or
* `\p{^..}`. Token names ignore case, spaces, hyphens, and underscores. You can omit the
* braces for token names that are a single letter (e.g. `\pL` or `PL`).
* - Adds flag A (astral), which enables 21-bit Unicode support.
* - Adds the `XRegExp.addUnicodeData` method used by other addons to provide character data.
*
* Unicode Base relies on externally provided Unicode character data. Official addons are
* available to provide data for Unicode categories, scripts, blocks, and properties.
*
* @requires XRegExp
*/
// ==--------------------------==
// Private stuff
// ==--------------------------==
// Storage for Unicode data
var unicode = {}; // Reuse utils
var dec = XRegExp._dec;
var hex = XRegExp._hex;
var pad4 = XRegExp._pad4; // Generates a token lookup name: lowercase, with hyphens, spaces, and underscores removed
function normalize(name) {
return name.replace(/[- _]+/g, '').toLowerCase();
} // Gets the decimal code of a literal code unit, \xHH, \uHHHH, or a backslash-escaped literal
function charCode(chr) {
var esc = /^\\[xu](.+)/.exec(chr);
return esc ? dec(esc[1]) : chr.charCodeAt(chr[0] === '\\' ? 1 : 0);
} // Inverts a list of ordered BMP characters and ranges
function invertBmp(range) {
var output = '';
var lastEnd = -1;
(0, _forEach.default)(XRegExp).call(XRegExp, range, /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, function (m) {
var start = charCode(m[1]);
if (start > lastEnd + 1) {
output += "\\u".concat(pad4(hex(lastEnd + 1)));
if (start > lastEnd + 2) {
output += "-\\u".concat(pad4(hex(start - 1)));
}
}
lastEnd = charCode(m[2] || m[1]);
});
if (lastEnd < 0xFFFF) {
output += "\\u".concat(pad4(hex(lastEnd + 1)));
if (lastEnd < 0xFFFE) {
output += '-\\uFFFF';
}
}
return output;
} // Generates an inverted BMP range on first use
function cacheInvertedBmp(slug) {
var prop = 'b!';
return unicode[slug][prop] || (unicode[slug][prop] = invertBmp(unicode[slug].bmp));
} // Combines and optionally negates BMP and astral data
function buildAstral(slug, isNegated) {
var item = unicode[slug];
var combined = '';
if (item.bmp && !item.isBmpLast) {
var _context;
combined = (0, _concat.default)(_context = "[".concat(item.bmp, "]")).call(_context, item.astral ? '|' : '');
}
if (item.astral) {
combined += item.astral;
}
if (item.isBmpLast && item.bmp) {
var _context2;
combined += (0, _concat.default)(_context2 = "".concat(item.astral ? '|' : '', "[")).call(_context2, item.bmp, "]");
} // Astral Unicode tokens always match a code point, never a code unit
return isNegated ? "(?:(?!".concat(combined, ")(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|[\0-\uFFFF]))") : "(?:".concat(combined, ")");
} // Builds a complete astral pattern on first use
function cacheAstral(slug, isNegated) {
var prop = isNegated ? 'a!' : 'a=';
return unicode[slug][prop] || (unicode[slug][prop] = buildAstral(slug, isNegated));
} // ==--------------------------==
// Core functionality
// ==--------------------------==
/*
* Add astral mode (flag A) and Unicode token syntax: `\p{..}`, `\P{..}`, `\p{^..}`, `\pC`.
*/
XRegExp.addToken( // Use `*` instead of `+` to avoid capturing `^` as the token name in `\p{^}`
/\\([pP])(?:{(\^?)([^}]*)}|([A-Za-z]))/, function (match, scope, flags) {
var ERR_DOUBLE_NEG = 'Invalid double negation ';
var ERR_UNKNOWN_NAME = 'Unknown Unicode token ';
var ERR_UNKNOWN_REF = 'Unicode token missing data ';
var ERR_ASTRAL_ONLY = 'Astral mode required for Unicode token ';
var ERR_ASTRAL_IN_CLASS = 'Astral mode does not support Unicode tokens within character classes'; // Negated via \P{..} or \p{^..}
var isNegated = match[1] === 'P' || !!match[2]; // Switch from BMP (0-FFFF) to astral (0-10FFFF) mode via flag A
var isAstralMode = (0, _includes.default)(flags).call(flags, 'A'); // Token lookup name. Check `[4]` first to avoid passing `undefined` via `\p{}`
var slug = normalize(match[4] || match[3]); // Token data object
var item = unicode[slug];
if (match[1] === 'P' && match[2]) {
throw new SyntaxError(ERR_DOUBLE_NEG + match[0]);
}
if (!unicode.hasOwnProperty(slug)) {
throw new SyntaxError(ERR_UNKNOWN_NAME + match[0]);
} // Switch to the negated form of the referenced Unicode token
if (item.inverseOf) {
slug = normalize(item.inverseOf);
if (!unicode.hasOwnProperty(slug)) {
var _context3;
throw new ReferenceError((0, _concat.default)(_context3 = "".concat(ERR_UNKNOWN_REF + match[0], " -> ")).call(_context3, item.inverseOf));
}
item = unicode[slug];
isNegated = !isNegated;
}
if (!(item.bmp || isAstralMode)) {
throw new SyntaxError(ERR_ASTRAL_ONLY + match[0]);
}
if (isAstralMode) {
if (scope === 'class') {
throw new SyntaxError(ERR_ASTRAL_IN_CLASS);
}
return cacheAstral(slug, isNegated);
}
return scope === 'class' ? isNegated ? cacheInvertedBmp(slug) : item.bmp : "".concat((isNegated ? '[^' : '[') + item.bmp, "]");
}, {
scope: 'all',
optionalFlags: 'A',
leadChar: '\\'
});
/**
* Adds to the list of Unicode tokens that XRegExp regexes can match via `\p` or `\P`.
*
* @memberOf XRegExp
* @param {Array} data Objects with named character ranges. Each object may have properties
* `name`, `alias`, `isBmpLast`, `inverseOf`, `bmp`, and `astral`. All but `name` are
* optional, although one of `bmp` or `astral` is required (unless `inverseOf` is set). If
* `astral` is absent, the `bmp` data is used for BMP and astral modes. If `bmp` is absent,
* the name errors in BMP mode but works in astral mode. If both `bmp` and `astral` are
* provided, the `bmp` data only is used in BMP mode, and the combination of `bmp` and
* `astral` data is used in astral mode. `isBmpLast` is needed when a token matches orphan
* high surrogates *and* uses surrogate pairs to match astral code points. The `bmp` and
* `astral` data should be a combination of literal characters and `\xHH` or `\uHHHH` escape
* sequences, with hyphens to create ranges. Any regex metacharacters in the data should be
* escaped, apart from range-creating hyphens. The `astral` data can additionally use
* character classes and alternation, and should use surrogate pairs to represent astral code
* points. `inverseOf` can be used to avoid duplicating character data if a Unicode token is
* defined as the exact inverse of another token.
* @example
*
* // Basic use
* XRegExp.addUnicodeData([{
* name: 'XDigit',
* alias: 'Hexadecimal',
* bmp: '0-9A-Fa-f'
* }]);
* XRegExp('\\p{XDigit}:\\p{Hexadecimal}+').test('0:3D'); // -> true
*/
XRegExp.addUnicodeData = function (data) {
var ERR_NO_NAME = 'Unicode token requires name';
var ERR_NO_DATA = 'Unicode token has no character data ';
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _getIterator2.default)(data), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
if (!item.name) {
throw new Error(ERR_NO_NAME);
}
if (!(item.inverseOf || item.bmp || item.astral)) {
throw new Error(ERR_NO_DATA + item.name);
}
unicode[normalize(item.name)] = item;
if (item.alias) {
unicode[normalize(item.alias)] = item;
}
} // Reset the pattern cache used by the `XRegExp` constructor, since the same pattern and
// flags might now produce different results
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
XRegExp.cache.flush('patterns');
};
/**
* @ignore
*
* Return a reference to the internal Unicode definition structure for the given Unicode
* Property if the given name is a legal Unicode Property for use in XRegExp `\p` or `\P` regex
* constructs.
*
* @memberOf XRegExp
* @param {String} name Name by which the Unicode Property may be recognized (case-insensitive),
* e.g. `'N'` or `'Number'`. The given name is matched against all registered Unicode
* Properties and Property Aliases.
* @returns {Object} Reference to definition structure when the name matches a Unicode Property.
*
* @note
* For more info on Unicode Properties, see also http://unicode.org/reports/tr18/#Categories.
*
* @note
* This method is *not* part of the officially documented API and may change or be removed in
* the future. It is meant for userland code that wishes to reuse the (large) internal Unicode
* structures set up by XRegExp.
*/
XRegExp._getUnicodeProperty = function (name) {
var slug = normalize(name);
return unicode[slug];
};
};
exports.default = _default;
module.exports = exports["default"];
},{"@babel/runtime-corejs3/core-js-stable/instance/concat":10,"@babel/runtime-corejs3/core-js-stable/instance/for-each":12,"@babel/runtime-corejs3/core-js-stable/instance/includes":13,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/core-js/get-iterator":23,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],4:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _blocks = _interopRequireDefault(require("../../tools/output/blocks"));
/*!
* XRegExp Unicode Blocks 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2010-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds support for all Unicode blocks. Block names use the prefix 'In'. E.g.,
* `\p{InBasicLatin}`. Token names are case insensitive, and any spaces, hyphens, and
* underscores are ignored.
*
* Uses Unicode 12.1.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Blocks');
}
XRegExp.addUnicodeData(_blocks.default);
};
exports.default = _default;
module.exports = exports["default"];
},{"../../tools/output/blocks":171,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],5:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _categories = _interopRequireDefault(require("../../tools/output/categories"));
/*!
* XRegExp Unicode Categories 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2010-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds support for Unicode's general categories. E.g., `\p{Lu}` or `\p{Uppercase Letter}`. See
* category descriptions in UAX #44 <http://unicode.org/reports/tr44/#GC_Values_Table>. Token
* names are case insensitive, and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 12.1.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Categories');
}
XRegExp.addUnicodeData(_categories.default);
};
exports.default = _default;
module.exports = exports["default"];
},{"../../tools/output/categories":172,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],6:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _properties = _interopRequireDefault(require("../../tools/output/properties"));
/*!
* XRegExp Unicode Properties 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2012-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds properties to meet the UTS #18 Level 1 RL1.2 requirements for Unicode regex support. See
* <http://unicode.org/reports/tr18/#RL1.2>. Following are definitions of these properties from
* UAX #44 <http://unicode.org/reports/tr44/>:
*
* - Alphabetic
* Characters with the Alphabetic property. Generated from: Lowercase + Uppercase + Lt + Lm +
* Lo + Nl + Other_Alphabetic.
*
* - Default_Ignorable_Code_Point
* For programmatic determination of default ignorable code points. New characters that should
* be ignored in rendering (unless explicitly supported) will be assigned in these ranges,
* permitting programs to correctly handle the default rendering of such characters when not
* otherwise supported.
*
* - Lowercase
* Characters with the Lowercase property. Generated from: Ll + Other_Lowercase.
*
* - Noncharacter_Code_Point
* Code points permanently reserved for internal use.
*
* - Uppercase
* Characters with the Uppercase property. Generated from: Lu + Other_Uppercase.
*
* - White_Space
* Spaces, separator characters and other control characters which should be treated by
* programming languages as "white space" for the purpose of parsing elements.
*
* The properties ASCII, Any, and Assigned are also included but are not defined in UAX #44. UTS
* #18 RL1.2 additionally requires support for Unicode scripts and general categories. These are
* included in XRegExp's Unicode Categories and Unicode Scripts addons.
*
* Token names are case insensitive, and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 12.1.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Properties');
}
var unicodeData = _properties.default; // Add non-generated data
unicodeData.push({
name: 'Assigned',
// Since this is defined as the inverse of Unicode category Cn (Unassigned), the Unicode
// Categories addon is required to use this property
inverseOf: 'Cn'
});
XRegExp.addUnicodeData(unicodeData);
};
exports.default = _default;
module.exports = exports["default"];
},{"../../tools/output/properties":173,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],7:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _scripts = _interopRequireDefault(require("../../tools/output/scripts"));
/*!
* XRegExp Unicode Scripts 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2010-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds support for all Unicode scripts. E.g., `\p{Latin}`. Token names are case insensitive,
* and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 12.1.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Scripts');
}
XRegExp.addUnicodeData(_scripts.default);
};
exports.default = _default;
module.exports = exports["default"];
},{"../../tools/output/scripts":174,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],8:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _xregexp = _interopRequireDefault(require("./xregexp"));
var _build = _interopRequireDefault(require("./addons/build"));
var _matchrecursive = _interopRequireDefault(require("./addons/matchrecursive"));
var _unicodeBase = _interopRequireDefault(require("./addons/unicode-base"));
var _unicodeBlocks = _interopRequireDefault(require("./addons/unicode-blocks"));
var _unicodeCategories = _interopRequireDefault(require("./addons/unicode-categories"));
var _unicodeProperties = _interopRequireDefault(require("./addons/unicode-properties"));
var _unicodeScripts = _interopRequireDefault(require("./addons/unicode-scripts"));
(0, _build.default)(_xregexp.default);
(0, _matchrecursive.default)(_xregexp.default);
(0, _unicodeBase.default)(_xregexp.default);
(0, _unicodeBlocks.default)(_xregexp.default);
(0, _unicodeCategories.default)(_xregexp.default);
(0, _unicodeProperties.default)(_xregexp.default);
(0, _unicodeScripts.default)(_xregexp.default);
var _default = _xregexp.default;
exports.default = _default;
module.exports = exports["default"];
},{"./addons/build":1,"./addons/matchrecursive":2,"./addons/unicode-base":3,"./addons/unicode-blocks":4,"./addons/unicode-categories":5,"./addons/unicode-properties":6,"./addons/unicode-scripts":7,"./xregexp":9,"@babel/runtime-corejs3/core-js-stable/object/define-property":20,"@babel/runtime-corejs3/helpers/interopRequireDefault":26}],9:[function(require,module,exports){
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
var _getIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator"));
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/sort"));
var _flags = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/flags"));
/*!
* XRegExp 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2007-present MIT License
*/
/**
* XRegExp provides augmented, extensible regular expressions. You get additional regex syntax and
* flags, beyond what browsers support natively. XRegExp is also a regex utility belt with tools to
* make your client-side grepping simpler and more powerful, while freeing you from related
* cross-browser inconsistencies.
*/
// ==--------------------------==
// Private stuff
// ==--------------------------==
// Property name used for extended regex instance data
var REGEX_DATA = 'xregexp'; // Optional features that can be installed and uninstalled
var features = {
astral: false,
namespacing: false
}; // Native methods to use and restore ('native' is an ES3 reserved keyword)
var nativ = {
exec: RegExp.prototype.exec,
test: RegExp.prototype.test,
match: String.prototype.match,
replace: String.prototype.replace,
split: String.prototype.split
}; // Storage for fixed/extended native methods
var fixed = {}; // Storage for regexes cached by `XRegExp.cache`
var regexCache = {}; // Storage for pattern details cached by the `XRegExp` constructor
var patternCache = {}; // Storage for regex syntax tokens added internally or by `XRegExp.addToken`
var tokens = []; // Token scopes
var defaultScope = 'default';
var classScope = 'class'; // Regexes that match native regex syntax, including octals
var nativeTokens = {
// Any native multicharacter token in default scope, or any single character
'default': /\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,
// Any native multicharacter token in character class scope, or any single character
'class': /\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/
}; // Any backreference or dollar-prefixed character in replacement strings
var replacementToken = /\$(?:{([\w$]+)}|<([\w$]+)>|(\d\d?|[\s\S]))/g; // Check for correct `exec` handling of nonparticipating capturing groups
var correctExecNpcg = nativ.exec.call(/()??/, '')[1] === undefined; // Check for ES6 `flags` prop support
var hasFlagsProp = (0, _flags.default)(/x/) !== undefined; // Shortcut to `Object.prototype.toString`
var _ref = {},
toString = _ref.toString;
function hasNativeFlag(flag) {
// Can't check based on the presence of properties/getters since browsers might support such
// properties even when they don't support the corresponding flag in regex construction (tested
// in Chrome 48, where `'unicode' in /x/` is true but trying to construct a regex with flag `u`
// throws an error)
var isSupported = true;
try {
// Can't use regex literals for testing even in a `try` because regex literals with
// unsupported flags cause a compilation error in IE
new RegExp('', flag);
} catch (exception) {
isSupported = false;
}
return isSupported;
} // Check for ES6 `u` flag support
var hasNativeU = hasNativeFlag('u'); // Check for ES6 `y` flag support
var hasNativeY = hasNativeFlag('y'); // Tracker for known flags, including addon flags
var registeredFlags = {
g: true,
i: true,
m: true,
u: hasNativeU,
y: hasNativeY
};
/**
* Attaches extended data and `XRegExp.prototype` properties to a regex object.
*
* @private
* @param {RegExp} regex Regex to augment.
* @param {Array} captureNames Array with capture names, or `null`.
* @param {String} xSource XRegExp pattern used to generate `regex`, or `null` if N/A.
* @param {String} xFlags XRegExp flags used to generate `regex`, or `null` if N/A.
* @param {Boolean} [isInternalOnly=false] Whether the regex will be used only for internal
* operations, and never exposed to users. For internal-only regexes, we can improve perf by
* skipping some operations like attaching `XRegExp.prototype` properties.
* @returns {RegExp} Augmented regex.
*/
function augment(regex, captureNames, xSource, xFlags, isInternalOnly) {
var _context;
regex[REGEX_DATA] = {
captureNames: captureNames
};
if (isInternalOnly) {
return regex;
} // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value
if (regex.__proto__) {
regex.__proto__ = XRegExp.prototype;
} else {
for (var p in XRegExp.prototype) {
// An `XRegExp.prototype.hasOwnProperty(p)` check wouldn't be worth it here, since this
// is performance sensitive, and enumerable `Object.prototype` or `RegExp.prototype`
// extensions exist on `regex.prototype` anyway
regex[p] = XRegExp.prototype[p];
}
}
regex[REGEX_DATA].source = xSource; // Emulate the ES6 `flags` prop by ensuring flags are in alphabetical order
regex[REGEX_DATA].flags = xFlags ? (0, _sort.default)(_context = xFlags.split('')).call(_context).join('') : xFlags;
return regex;
}
/**
* Removes any duplicate characters from the provided string.
*
* @private
* @param {String} str String to remove duplicate characters from.
* @returns {String} String with any duplicate characters removed.
*/
function clipDuplicates(str) {
return nativ.replace.call(str, /([\s\S])(?=[\s\S]*\1)/g, '');
}
/**
* Copies a regex object while preserving extended data and augmenting with `XRegExp.prototype`
* properties. The copy has a fresh `lastIndex` property (set to zero). Allows adding and removing
* flags g and y while copying the regex.
*
* @private
* @param {RegExp} regex Regex to copy.
* @param {Object} [options] Options object with optional properties:
* - `addG` {Boolean} Add flag g while copying the regex.
* - `addY` {Boolean} Add flag y while copying the regex.
* - `removeG` {Boolean} Remove flag g while copying the regex.
* - `removeY` {Boolean} Remove flag y while copying the regex.
* - `isInternalOnly` {Boolean} Whether the copied regex will be used only for internal
* operations, and never exposed to users. For internal-only regexes, we can improve perf by
* skipping some operations like attaching `XRegExp.prototype` properties.
* - `source` {String} Overrides `<regex>.source`, for special cases.
* @returns {RegExp} Copy of the provided regex, possibly with modified flags.
*/
function copyRegex(regex, options) {
var _context2;
if (!XRegExp.isRegExp(regex)) {
throw new TypeError('Type RegExp expected');
}
var xData = regex[REGEX_DATA] || {};
var flags = getNativeFlags(regex);
var flagsToAdd = '';
var flagsToRemove = '';
var xregexpSource = null;
var xregexpFlags = null;
options = options || {};
if (options.removeG) {
flagsToRemove += 'g';
}
if (options.removeY) {
flagsToRemove += 'y';
}
if (flagsToRemove) {
flags = nativ.replace.call(flags, new RegExp("[".concat(flagsToRemove, "]+"), 'g'), '');
}
if (options.addG) {
flagsToAdd += 'g';
}
if (options.addY) {
flagsToAdd += 'y';
}
if (flagsToAdd) {
flags = clipDuplicates(flags + flagsToAdd);
}
if (!options.isInternalOnly) {
if (xData.source !== undefined) {
xregexpSource = xData.source;
} // null or undefined; don't want to add to `flags` if the previous value was null, since
// that indicates we're not tracking original precompilation flags
if ((0, _flags.default)(xData) != null) {
// Flags are only added for non-internal regexes by `XRegExp.globalize`. Flags are never
// removed for non-internal regexes, so don't need to handle it
xregexpFlags = flagsToAdd ? clipDuplicates((0, _flags.default)(xData) + flagsToAdd) : (0, _flags.default)(xData);
}
} // Augment with `XRegExp.prototype` properties, but use the native `RegExp` constructor to avoid
// searching for special tokens. That would be wrong for regexes constructed by `RegExp`, and
// unnecessary for regexes constructed by `XRegExp` because the regex has already undergone the
// translation to native regex syntax
regex = augment(new RegExp(options.source || regex.source, flags), hasNamedCapture(regex) ? (0, _slice.default)(_context2 = xData.captureNames).call(_context2, 0) : null, xregexpSource, xregexpFlags, options.isInternalOnly);
return regex;
}
/**
* Converts hexadecimal to decimal.
*
* @private
* @param {String} hex
* @returns {Number}
*/
function dec(hex) {
return (0, _parseInt2.default)(hex, 16);
}
/**
* Returns a pattern that can be used in a native RegExp in place of an ignorable token such as an
* inline comment or whitespace with flag x. This is used directly as a token handler function
* passed to `XRegExp.addToken`.
*
* @private
* @param {String} match Match arg of `XRegExp.addToken` handler
* @param {String} scope Scope arg of `XRegExp.addToken` handler
* @param {String} flags Flags arg of `XRegExp.addToken` handle