Comparing version 5.0.0 to 5.0.1
@@ -22,3 +22,3 @@ "use strict"; | ||
/*! | ||
* XRegExp.build 4.4.1 | ||
* XRegExp.build 5.0.1 | ||
* <xregexp.com> | ||
@@ -101,10 +101,13 @@ * Steven Levithan (c) 2012-present MIT License | ||
* | ||
* 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}) $`; | ||
* XRegExp.tag()`\b\w+\b`.test('word'); // -> true | ||
* | ||
* const hours = /1[0-2]|0?[1-9]/; | ||
* const minutes = /(?<minutes>[0-5][0-9])/; | ||
* const time = XRegExp.tag('x')`\b ${hours} : ${minutes} \b`; | ||
* time.test('10:59'); // -> true | ||
* XRegExp.exec('10:59', time).minutes; // -> '59' | ||
* XRegExp.exec('10:59', time).groups.minutes; // -> '59' | ||
* | ||
* const backref1 = /(a)\1/; | ||
* const backref2 = /(b)\1/; | ||
* XRegExp.tag()`${backref1}${backref2}`.test('aabb'); // -> true | ||
*/ | ||
@@ -149,3 +152,3 @@ | ||
* time.test('10:59'); // -> true | ||
* XRegExp.exec('10:59', time).minutes; // -> '59' | ||
* XRegExp.exec('10:59', time).groups.minutes; // -> '59' | ||
*/ | ||
@@ -152,0 +155,0 @@ |
@@ -20,3 +20,3 @@ "use strict"; | ||
/*! | ||
* XRegExp.matchRecursive 4.4.1 | ||
* XRegExp.matchRecursive 5.0.1 | ||
* <xregexp.com> | ||
@@ -48,3 +48,3 @@ * Steven Levithan (c) 2009-present MIT License | ||
* @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 {String} [flags] Any combination of XRegExp flags, used for the left and right delimiters. | ||
* @param {Object} [options] Lets you specify `valueNames` and `escapeChar` options. | ||
@@ -135,3 +135,3 @@ * @returns {!Array} Array of matches, or an empty array. | ||
}).source, ")[^")).call(_context, escapeChar, "])+)+"), // Flags `gy` not needed here | ||
flags.replace(/[^imu]+/g, '')); | ||
flags.replace(XRegExp._hasNativeFlag('s') ? /[^imsu]/g : /[^imu]/g, '')); | ||
} | ||
@@ -214,3 +214,7 @@ | ||
} else { | ||
throw new Error('Unbalanced delimiter found in string'); | ||
var _context3; | ||
var delimSide = rightMatch ? 'right' : 'left'; | ||
var errorPos = rightMatch ? delimStart : outerStart; | ||
throw new Error((0, _concat["default"])(_context3 = "Unbalanced ".concat(delimSide, " delimiter found in string at position ")).call(_context3, errorPos)); | ||
} // If the delimiter matched an empty string, avoid an infinite loop | ||
@@ -217,0 +221,0 @@ |
@@ -27,2 +27,4 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray")); | ||
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat")); | ||
@@ -39,3 +41,3 @@ | ||
/*! | ||
* XRegExp Unicode Base 4.4.1 | ||
* XRegExp Unicode Base 5.0.1 | ||
* <xregexp.com> | ||
@@ -54,3 +56,3 @@ * Steven Levithan (c) 2008-present MIT License | ||
* Unicode Base relies on externally provided Unicode character data. Official addons are | ||
* available to provide data for Unicode categories, scripts, blocks, and properties. | ||
* available to provide data for Unicode categories, scripts, and properties. | ||
* | ||
@@ -63,3 +65,4 @@ * @requires XRegExp | ||
// Storage for Unicode data | ||
var unicode = {}; // Reuse utils | ||
var unicode = {}; | ||
var unicodeTypes = {}; // Reuse utils | ||
@@ -154,3 +157,3 @@ var dec = XRegExp._dec; | ||
XRegExp.addToken( // Use `*` instead of `+` to avoid capturing `^` as the token name in `\p{^}` | ||
/\\([pP])(?:{(\^?)([^}]*)}|([A-Za-z]))/, function (match, scope, flags) { | ||
/\\([pP])(?:{(\^?)(?:(\w+)=)?([^}]*)}|([A-Za-z]))/, function (match, scope, flags) { | ||
var ERR_DOUBLE_NEG = 'Invalid double negation '; | ||
@@ -160,18 +163,34 @@ var ERR_UNKNOWN_NAME = 'Unknown Unicode token '; | ||
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 ERR_ASTRAL_IN_CLASS = 'Astral mode does not support Unicode tokens within character classes'; | ||
var isNegated = match[1] === 'P' || !!match[2]; // Switch from BMP (0-FFFF) to astral (0-10FFFF) mode via flag A | ||
var _match = (0, _slicedToArray2["default"])(match, 6), | ||
fullToken = _match[0], | ||
pPrefix = _match[1], | ||
caretNegation = _match[2], | ||
typePrefix = _match[3], | ||
tokenName = _match[4], | ||
tokenSingleCharName = _match[5]; // Negated via \P{..} or \p{^..} | ||
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 isNegated = pPrefix === 'P' || !!caretNegation; // 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 `tokenSingleCharName` first to avoid passing `undefined` | ||
// via `\p{}` | ||
var slug = normalize(tokenSingleCharName || tokenName); // Token data object | ||
var item = unicode[slug]; | ||
if (match[1] === 'P' && match[2]) { | ||
throw new SyntaxError(ERR_DOUBLE_NEG + match[0]); | ||
if (pPrefix === 'P' && caretNegation) { | ||
throw new SyntaxError(ERR_DOUBLE_NEG + fullToken); | ||
} | ||
if (!unicode.hasOwnProperty(slug)) { | ||
throw new SyntaxError(ERR_UNKNOWN_NAME + match[0]); | ||
throw new SyntaxError(ERR_UNKNOWN_NAME + fullToken); | ||
} | ||
if (typePrefix) { | ||
if (!(unicodeTypes[typePrefix] && unicodeTypes[typePrefix][slug])) { | ||
throw new SyntaxError(ERR_UNKNOWN_NAME + fullToken); | ||
} | ||
} // Switch to the negated form of the referenced Unicode token | ||
@@ -186,3 +205,3 @@ | ||
throw new ReferenceError((0, _concat["default"])(_context3 = "".concat(ERR_UNKNOWN_REF + match[0], " -> ")).call(_context3, item.inverseOf)); | ||
throw new ReferenceError((0, _concat["default"])(_context3 = "".concat(ERR_UNKNOWN_REF + fullToken, " -> ")).call(_context3, item.inverseOf)); | ||
} | ||
@@ -195,3 +214,3 @@ | ||
if (!(item.bmp || isAstralMode)) { | ||
throw new SyntaxError(ERR_ASTRAL_ONLY + match[0]); | ||
throw new SyntaxError(ERR_ASTRAL_ONLY + fullToken); | ||
} | ||
@@ -231,2 +250,5 @@ | ||
* defined as the exact inverse of another token. | ||
* @param {String} [typePrefix] Enables optionally using this type as a prefix for all of the | ||
* provided Unicode tokens, e.g. if given `'Type'`, then `\p{TokenName}` can also be written | ||
* as `\p{Type=TokenName}`. | ||
* @example | ||
@@ -243,6 +265,11 @@ * | ||
XRegExp.addUnicodeData = function (data) { | ||
XRegExp.addUnicodeData = function (data, typePrefix) { | ||
var ERR_NO_NAME = 'Unicode token requires name'; | ||
var ERR_NO_DATA = 'Unicode token has no character data '; | ||
if (typePrefix) { | ||
// Case sensitive to match ES2018 | ||
unicodeTypes[typePrefix] = {}; | ||
} | ||
var _iterator = _createForOfIteratorHelper(data), | ||
@@ -263,6 +290,16 @@ _step; | ||
unicode[normalize(item.name)] = item; | ||
var normalizedName = normalize(item.name); | ||
unicode[normalizedName] = item; | ||
if (typePrefix) { | ||
unicodeTypes[typePrefix][normalizedName] = true; | ||
} | ||
if (item.alias) { | ||
unicode[normalize(item.alias)] = item; | ||
var normalizedAlias = normalize(item.alias); | ||
unicode[normalizedAlias] = item; | ||
if (typePrefix) { | ||
unicodeTypes[typePrefix][normalizedAlias] = true; | ||
} | ||
} | ||
@@ -269,0 +306,0 @@ } // Reset the pattern cache used by the `XRegExp` constructor, since the same pattern and |
@@ -16,3 +16,3 @@ "use strict"; | ||
/*! | ||
* XRegExp Unicode Categories 4.4.1 | ||
* XRegExp Unicode Categories 5.0.1 | ||
* <xregexp.com> | ||
@@ -19,0 +19,0 @@ * Steven Levithan (c) 2010-present MIT License |
@@ -16,3 +16,3 @@ "use strict"; | ||
/*! | ||
* XRegExp Unicode Properties 4.4.1 | ||
* XRegExp Unicode Properties 5.0.1 | ||
* <xregexp.com> | ||
@@ -19,0 +19,0 @@ * Steven Levithan (c) 2012-present MIT License |
@@ -16,3 +16,3 @@ "use strict"; | ||
/*! | ||
* XRegExp Unicode Scripts 4.4.1 | ||
* XRegExp Unicode Scripts 5.0.1 | ||
* <xregexp.com> | ||
@@ -35,3 +35,3 @@ * Steven Levithan (c) 2010-present MIT License | ||
XRegExp.addUnicodeData(_scripts["default"]); | ||
XRegExp.addUnicodeData(_scripts["default"], 'Script'); | ||
}; | ||
@@ -38,0 +38,0 @@ |
@@ -21,4 +21,2 @@ "use strict"; | ||
var _unicodeBlocks = _interopRequireDefault(require("./addons/unicode-blocks")); | ||
var _unicodeCategories = _interopRequireDefault(require("./addons/unicode-categories")); | ||
@@ -33,3 +31,2 @@ | ||
(0, _unicodeBase["default"])(_xregexp["default"]); | ||
(0, _unicodeBlocks["default"])(_xregexp["default"]); | ||
(0, _unicodeCategories["default"])(_xregexp["default"]); | ||
@@ -36,0 +33,0 @@ (0, _unicodeProperties["default"])(_xregexp["default"]); |
{ | ||
"name": "xregexp", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Extended regular expressions", | ||
@@ -5,0 +5,0 @@ "homepage": "http://xregexp.com/", |
@@ -1,2 +0,2 @@ | ||
# XRegExp 5.0.0-next | ||
# XRegExp 5.0.1 | ||
@@ -3,0 +3,0 @@ [![Build Status](https://github.com/slevithan/xregexp/workflows/Node.js%20CI/badge.svg)](https://github.com/slevithan/xregexp/actions) |
/*! | ||
* XRegExp.build 5.0.0 | ||
* XRegExp.build 5.0.1 | ||
* <xregexp.com> | ||
@@ -4,0 +4,0 @@ * Steven Levithan (c) 2012-present MIT License |
/*! | ||
* XRegExp.matchRecursive 5.0.0 | ||
* XRegExp.matchRecursive 5.0.1 | ||
* <xregexp.com> | ||
@@ -4,0 +4,0 @@ * Steven Levithan (c) 2009-present MIT License |
/*! | ||
* XRegExp Unicode Base 5.0.0 | ||
* XRegExp Unicode Base 5.0.1 | ||
* <xregexp.com> | ||
@@ -18,3 +18,3 @@ * Steven Levithan (c) 2008-present MIT License | ||
* Unicode Base relies on externally provided Unicode character data. Official addons are | ||
* available to provide data for Unicode categories, scripts, blocks, and properties. | ||
* available to provide data for Unicode categories, scripts, and properties. | ||
* | ||
@@ -21,0 +21,0 @@ * @requires XRegExp |
/*! | ||
* XRegExp Unicode Categories 5.0.0 | ||
* XRegExp Unicode Categories 5.0.1 | ||
* <xregexp.com> | ||
@@ -4,0 +4,0 @@ * Steven Levithan (c) 2010-present MIT License |
/*! | ||
* XRegExp Unicode Properties 5.0.0 | ||
* XRegExp Unicode Properties 5.0.1 | ||
* <xregexp.com> | ||
@@ -4,0 +4,0 @@ * Steven Levithan (c) 2012-present MIT License |
/*! | ||
* XRegExp Unicode Scripts 5.0.0 | ||
* XRegExp Unicode Scripts 5.0.1 | ||
* <xregexp.com> | ||
@@ -4,0 +4,0 @@ * Steven Levithan (c) 2010-present MIT License |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
13
1
769531
24
13618