Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xregexp

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xregexp - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

lib/addons/build.js

24

package.json
{
"name": "xregexp",
"version": "3.2.0",
"version": "4.0.0",
"description": "Extended regular expressions",

@@ -18,5 +18,6 @@ "homepage": "http://xregexp.com/",

],
"main": "xregexp-all.js",
"main": "./lib",
"files": [
"src",
"lib",
"xregexp-all.js",

@@ -26,10 +27,23 @@ "LICENSE"

"scripts": {
"build": "browserify src/index.js --standalone XRegExp > xregexp-all.js",
"lint": "eslint src",
"babel": "babel src -d lib",
"prebuild": "npm run lint && npm run babel",
"build": "browserify lib/index.js --standalone XRegExp > xregexp-all.js",
"pretest": "npm run build",
"test": "jasmine JASMINE_CONFIG_PATH=tests/jasmine.json"
"test": "jasmine JASMINE_CONFIG_PATH=tests/jasmine.json",
"test-saucelabs": "npm run pretest && zuul tests/spec/*.js",
"test-browser": "npm run test-saucelabs -- --local --open",
"prepublish": "npm test"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-xregexp": "^0.0.4",
"babel-preset-env": "^1.4.0",
"browserify": "^12.0.1",
"jasmine": "^2.5.3"
"eslint": "^3.19.0",
"jasmine": "^2.5.3",
"zuul": "^3.11.1"
}
}

@@ -1,2 +0,2 @@

# XRegExp 3.2.0
# XRegExp 4.0.0

@@ -7,3 +7,3 @@ [![Build Status](https://travis-ci.org/slevithan/xregexp.svg?branch=master)](https://travis-ci.org/slevithan/xregexp)

XRegExp supports all native ES6 regular expression syntax. It supports Internet Explorer 5.5+, Firefox 1.5+, Chrome, Safari 3+, and Opera 11+. You can use it with Node.js or as a RequireJS module.
XRegExp supports all native ES6 regular expression syntax. It supports ES5+ browsers, and you can use it with Node.js or as a RequireJS module.

@@ -17,25 +17,26 @@ ## Performance

```js
// Using named capture and flag x (free-spacing and line comments)
var date = XRegExp(`(?<year> [0-9]{4} ) -? # year
(?<month> [0-9]{2} ) -? # month
(?<day> [0-9]{2} ) # day`, 'x');
// Using named capture and flag x for free-spacing and line comments
const date = XRegExp(
`(?<year> [0-9]{4} ) -? # year
(?<month> [0-9]{2} ) -? # month
(?<day> [0-9]{2} ) # day`, 'x');
// XRegExp.exec gives you named backreferences on the match result
var match = XRegExp.exec('2017-02-22', date);
let match = XRegExp.exec('2017-02-22', date);
match.year; // -> '2017'
// It also includes optional pos and sticky arguments
var pos = 3;
var result = [];
while (match = XRegExp.exec('<1><2><3><4>5<6>', /<(\d+)>/, pos, 'sticky')) {
let pos = 3;
const result = [];
while (match = XRegExp.exec('<1><2><3>4<5>', /<(\d+)>/, pos, 'sticky')) {
result.push(match[1]);
pos = match.index + match[0].length;
}
// result -> ['2', '3', '4']
// result -> ['2', '3']
// XRegExp.replace allows named backreferences in replacements
XRegExp.replace('2017-02-22', date, '${month}/${day}/${year}');
XRegExp.replace('2017-02-22', date, '$<month>/$<day>/$<year>');
// -> '02/22/2017'
XRegExp.replace('2017-02-22', date, (match) => {
return match.month + '/' + match.day + '/' + match.year;
return `${match.month}/${match.day}/${match.year}`;
});

@@ -48,4 +49,4 @@ // -> '02/22/2017'

// The only caveat is that named captures must be referenced using numbered
// backreferences if used with native methods
// The only caveat is that named captures must be referenced using
// numbered backreferences if used with native methods
'2017-02-22'.replace(date, '$2/$3/$1');

@@ -55,3 +56,3 @@ // -> '02/22/2017'

// Use XRegExp.forEach to extract every other digit from a string
var evens = [];
const evens = [];
XRegExp.forEach('1a2345', /\d/, (match, i) => {

@@ -70,4 +71,5 @@ if (i % 2) evens.push(+match[0]);

// You can also pass forward and return specific backreferences
var html = '<a href="http://xregexp.com/">XRegExp</a>' +
'<a href="http://www.google.com/">Google</a>';
const html =
`<a href="http://xregexp.com/">XRegExp</a>
<a href="http://www.google.com/">Google</a>`;
XRegExp.matchChain(html, [

@@ -79,5 +81,5 @@ {regex: /<a href="([^"]+)">/i, backref: 1},

// Merge strings and regexes into a single pattern with updated backreferences
XRegExp.union(['a+b*c', /(dog)\1/, /(cat)\1/], 'i', {conjunction: 'or'});
// -> /a\+b\*c|(dog)\1|(cat)\2/i
// Merge strings and regexes, with updated backreferences
XRegExp.union(['m+a*n', /(bear)\1/, /(pig)\1/], 'i', {conjunction: 'or'});
// -> /m\+a\*n|(bear)\1|(pig)\2/i
```

@@ -89,3 +91,3 @@

You can either load addons individually, or bundle all addons with XRegExp by loading `xregexp-all.js`.
You can either load addons individually, or bundle all addons with XRegExp by loading `xregexp-all.js` from https://unpkg.com/xregexp/xregexp-all.js.

@@ -100,3 +102,3 @@ ### Unicode

// Test the Unicode category L (Letter)
var unicodeWord = XRegExp('^\\pL+$');
const unicodeWord = XRegExp('^\\pL+$');
unicodeWord.test('Русский'); // -> true

@@ -135,3 +137,3 @@ unicodeWord.test('日本語'); // -> true

```js
var time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
const time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
hours: XRegExp.build('{{h12}} : | {{h24}}', {

@@ -150,4 +152,19 @@ h12: /1[0-2]|0?[1-9]/,

See also: *[Creating Grammatical Regexes Using XRegExp.build](http://blog.stevenlevithan.com/archives/grammatical-patterns-xregexp-build)*.
#### XRegExp.tag (included with XRegExp.build)
Provides tagged template literals that create regexes with XRegExp syntax and flags:
```js
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 does more than just basic interpolation. For starters, you get all the XRegExp syntax and flags. Even better, since `XRegExp.tag` uses your pattern as a raw string, you no longer need to escape all your backslashes. And since it relies on `XRegExp.build` under the hood, you get all of its extras for free. Leading `^` and trailing unescaped `$` are stripped from interpolated patterns if both are present (to allow embedding independently useful anchored regexes), interpolating into a character class is an error (to avoid unintended meaning in edge cases), interpolated patterns are treated as atomic units when quantified, interpolated strings have their special characters escaped, and any backreferences within an interpolated regex are rewritten to work within the overall pattern.
### XRegExp.matchRecursive

@@ -158,9 +175,9 @@

```js
var str = '(t((e))s)t()(ing)';
XRegExp.matchRecursive(str, '\\(', '\\)', 'g');
const str1 = '(t((e))s)t()(ing)';
XRegExp.matchRecursive(str1, '\\(', '\\)', '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', {
const str2 = 'Here is <div> <div>an</div></div> example';
XRegExp.matchRecursive(str2, '<div\\s*>', '</div>', 'gi', {
valueNames: ['between', 'left', 'match', 'right']

@@ -177,4 +194,4 @@ });

// Omitting unneeded parts with null valueNames, and using escapeChar
str = '...{1}.\\{{function(x,y){return {y:x}}}';
XRegExp.matchRecursive(str, '{', '}', 'g', {
const str3 = '...{1}.\\{{function(x,y){return {y:x}}}';
XRegExp.matchRecursive(str3, '{', '}', 'g', {
valueNames: ['literal', null, 'value', null],

@@ -191,4 +208,4 @@ escapeChar: '\\'

// Sticky mode via flag y
str = '<1><<<2>>><3>4<5>';
XRegExp.matchRecursive(str, '<', '>', 'gy');
const str4 = '<1><<<2>>><3>4<5>';
XRegExp.matchRecursive(str4, '<', '>', 'gy');
// -> ['1', '<<2>>', '3']

@@ -204,3 +221,3 @@ ```

```html
<script src="xregexp-all.js"></script>
<script src="https://unpkg.com/xregexp/xregexp-all.js"></script>
```

@@ -217,3 +234,3 @@

```js
var XRegExp = require('xregexp');
const XRegExp = require('xregexp');
```

@@ -220,0 +237,0 @@

/*!
* XRegExp.build 3.2.0
* XRegExp.build 4.0.0
* <xregexp.com>
* Steven Levithan (c) 2012-2017 MIT License
* Inspired by Lea Verou's RegExp.create <lea.verou.me>
*/
module.exports = function(XRegExp) {
'use strict';
var REGEX_DATA = 'xregexp';
var subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g;
var parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g', {
export default (XRegExp) => {
const REGEX_DATA = 'xregexp';
const subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g;
const parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g', {
conjunction: 'or'

@@ -27,4 +24,4 @@ });

// built/generated by XRegExp sometimes include them
var leadingAnchor = /^(?:\(\?:\))*\^/;
var trailingAnchor = /\$(?:\(\?:\))*$/;
const leadingAnchor = /^(?:\(\?:\))*\^/;
const trailingAnchor = /\$(?:\(\?:\))*$/;

@@ -53,3 +50,3 @@ if (

function asXRegExp(value, addFlagX) {
var flags = addFlagX ? 'x' : '';
const flags = addFlagX ? 'x' : '';
return XRegExp.isRegExp(value) ?

@@ -66,3 +63,47 @@ (value[REGEX_DATA] && value[REGEX_DATA].captureNames ?

function interpolate(substitution) {
return substitution instanceof RegExp ? substitution : XRegExp.escape(substitution);
}
function reduceToSubpatternsObject(subpatterns, interpolated, subpatternIndex) {
subpatterns[`subpattern${subpatternIndex}`] = interpolated;
return subpatterns;
}
function embedSubpatternAfter(raw, subpatternIndex, rawLiterals) {
const hasSubpattern = subpatternIndex < rawLiterals.length - 1;
return raw + (hasSubpattern ? `{{subpattern${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 = (flags) => (literals, ...substitutions) => {
const subpatterns = substitutions.map(interpolate).reduce(reduceToSubpatternsObject, {});
const pattern = literals.raw.map(embedSubpatternAfter).join('');
return XRegExp.build(pattern, subpatterns, flags);
};
/**
* Builds regexes using named subpatterns, for readability and pattern reuse. Backreferences in

@@ -82,3 +123,3 @@ * the outer pattern and provided subpatterns are automatically renumbered to work correctly.

*
* var time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
* const time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
* hours: XRegExp.build('{{h12}} : | {{h24}}', {

@@ -93,3 +134,3 @@ * h12: /1[0-2]|0?[1-9]/,

*/
XRegExp.build = function(pattern, subs, flags) {
XRegExp.build = (pattern, subs, flags) => {
flags = flags || '';

@@ -99,4 +140,4 @@ // Used with `asXRegExp` calls for `pattern` and subpatterns in `subs`, to work around how

// and `n`. See more details at <https://github.com/slevithan/xregexp/pull/163>.
var addFlagX = flags.indexOf('x') > -1;
var inlineFlags = /^\(\?([\w$]+)\)/.exec(pattern);
const addFlagX = flags.includes('x');
const inlineFlags = /^\(\?([\w$]+)\)/.exec(pattern);
// Add flags within a leading mode modifier to the overall pattern's flags

@@ -107,4 +148,4 @@ if (inlineFlags) {

var data = {};
for (var p in subs) {
const data = {};
for (const p in subs) {
if (subs.hasOwnProperty(p)) {

@@ -115,3 +156,3 @@ // Passing to XRegExp enables extended syntax and ensures independent validity,

// used to hold extended regex instance data, for simplicity.
var sub = asXRegExp(subs[p], addFlagX);
const sub = asXRegExp(subs[p], addFlagX);
data[p] = {

@@ -128,19 +169,19 @@ // Deanchoring allows embedding independently useful anchored regexes. If you

// helps keep this simple. Named captures will be put back.
var patternAsRegex = asXRegExp(pattern, addFlagX);
const 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;
let numCaps = 0;
let numPriorCaps;
let numOuterCaps = 0;
const outerCapsMap = [0];
const outerCapNames = patternAsRegex[REGEX_DATA].captureNames || [];
const output = patternAsRegex.source.replace(parts, ($0, $1, $2, $3, $4) => {
const subName = $1 || $2;
let capName;
let intro;
let localCapIndex;
// Named subpattern
if (subName) {
if (!data.hasOwnProperty(subName)) {
throw new ReferenceError('Undefined property ' + $0);
throw new ReferenceError(`Undefined property ${$0}`);
}

@@ -153,3 +194,3 @@ // Named subpattern was wrapped in a capturing group

// as the capture name
intro = '(?<' + (capName || subName) + '>';
intro = `(?<${capName || subName}>`;
} else {

@@ -159,3 +200,3 @@ intro = '(?:';

numPriorCaps = numCaps;
return intro + data[subName].pattern.replace(subParts, function(match, paren, backref) {
const rewrittenSubpattern = data[subName].pattern.replace(subParts, (match, paren, backref) => {
// Capturing group

@@ -167,3 +208,3 @@ if (paren) {

if (capName) {
return '(?<' + capName + '>';
return `(?<${capName}>`;
}

@@ -176,7 +217,8 @@ // Backreference

// Need to preserve the backreference name in case using flag `n`
'\\k<' + data[subName].names[localCapIndex] + '>' :
'\\' + (+backref + numPriorCaps);
`\\k<${data[subName].names[localCapIndex]}>` :
`\\${+backref + numPriorCaps}`;
}
return match;
}) + ')';
});
return `${intro}${rewrittenSubpattern})`;
}

@@ -189,3 +231,3 @@ // Capturing group

if (capName) {
return '(?<' + capName + '>';
return `(?<${capName}>`;
}

@@ -198,4 +240,4 @@ // Backreference

// Need to preserve the backreference name in case using flag `n`
'\\k<' + outerCapNames[localCapIndex] + '>' :
'\\' + outerCapsMap[+$4];
`\\k<${outerCapNames[localCapIndex]}>` :
`\\${outerCapsMap[+$4]}`;
}

@@ -207,3 +249,2 @@ return $0;

};
};
/*!
* XRegExp.matchRecursive 3.2.0
* XRegExp.matchRecursive 4.0.0
* <xregexp.com>

@@ -7,4 +7,3 @@ * Steven Levithan (c) 2009-2017 MIT License

module.exports = function(XRegExp) {
'use strict';
export default (XRegExp) => {

@@ -18,6 +17,6 @@ /**

return {
name: name,
value: value,
start: start,
end: end
name,
value,
start,
end
};

@@ -41,3 +40,3 @@ }

* // Basic usage
* var str = '(t((e))s)t()(ing)';
* let str = '(t((e))s)t()(ing)';
* XRegExp.matchRecursive(str, '\\(', '\\)', 'g');

@@ -77,21 +76,21 @@ * // -> ['t((e))s', '', 'ing']

*/
XRegExp.matchRecursive = function(str, left, right, flags, options) {
XRegExp.matchRecursive = (str, left, right, flags, options) => {
flags = flags || '';
options = options || {};
var global = flags.indexOf('g') > -1;
var sticky = flags.indexOf('y') > -1;
const global = flags.includes('g');
const sticky = flags.includes('y');
// Flag `y` is controlled internally
var basicFlags = flags.replace(/y/g, '');
var 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;
const basicFlags = flags.replace(/y/g, '');
let escapeChar = options.escapeChar;
const vN = options.valueNames;
const output = [];
let openTokens = 0;
let delimStart = 0;
let delimEnd = 0;
let lastOuterEnd = 0;
let outerStart;
let innerStart;
let leftMatch;
let rightMatch;
let esc;
left = XRegExp(left, basicFlags);

@@ -111,3 +110,3 @@ right = XRegExp(right, basicFlags);

esc = new RegExp(
'(?:' + escapeChar + '[\\S\\s]|(?:(?!' +
`(?:${escapeChar}[\\S\\s]|(?:(?!${
// Using `XRegExp.union` safely rewrites backreferences in `left` and `right`.

@@ -117,4 +116,4 @@ // Intentionally not passing `basicFlags` to `XRegExp.union` since any syntax

// `right` when they were passed through the XRegExp constructor above.
XRegExp.union([left, right], '', {conjunction: 'or'}).source +
')[^' + escapeChar + '])+)+',
XRegExp.union([left, right], '', {conjunction: 'or'}).source
})[^${escapeChar}])+)+`,
// Flags `gy` not needed here

@@ -204,3 +203,2 @@ flags.replace(/[^imu]+/g, '')

};
};
/*!
* XRegExp Unicode Base 3.2.0
* XRegExp Unicode Base 4.0.0
* <xregexp.com>

@@ -7,4 +7,3 @@ * Steven Levithan (c) 2008-2017 MIT License

module.exports = function(XRegExp) {
'use strict';
export default (XRegExp) => {

@@ -30,8 +29,8 @@ /**

// Storage for Unicode data
var unicode = {};
const unicode = {};
// Reuse utils
var dec = XRegExp._dec;
var hex = XRegExp._hex;
var pad4 = XRegExp._pad4;
const dec = XRegExp._dec;
const hex = XRegExp._hex;
const pad4 = XRegExp._pad4;

@@ -45,6 +44,6 @@ // Generates a token lookup name: lowercase, with hyphens, spaces, and underscores removed

function charCode(chr) {
var esc = /^\\[xu](.+)/.exec(chr);
const esc = /^\\[xu](.+)/.exec(chr);
return esc ?
dec(esc[1]) :
chr.charCodeAt(chr.charAt(0) === '\\' ? 1 : 0);
chr.charCodeAt(chr[0] === '\\' ? 1 : 0);
}

@@ -54,4 +53,4 @@

function invertBmp(range) {
var output = '';
var lastEnd = -1;
let output = '';
let lastEnd = -1;

@@ -61,8 +60,8 @@ XRegExp.forEach(

/(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/,
function(m) {
var start = charCode(m[1]);
(m) => {
const start = charCode(m[1]);
if (start > (lastEnd + 1)) {
output += '\\u' + pad4(hex(lastEnd + 1));
output += `\\u${pad4(hex(lastEnd + 1))}`;
if (start > (lastEnd + 2)) {
output += '-\\u' + pad4(hex(start - 1));
output += `-\\u${pad4(hex(start - 1))}`;
}

@@ -75,3 +74,3 @@ }

if (lastEnd < 0xFFFF) {
output += '\\u' + pad4(hex(lastEnd + 1));
output += `\\u${pad4(hex(lastEnd + 1))}`;
if (lastEnd < 0xFFFE) {

@@ -87,3 +86,3 @@ output += '-\\uFFFF';

function cacheInvertedBmp(slug) {
var prop = 'b!';
const prop = 'b!';
return (

@@ -97,7 +96,7 @@ unicode[slug][prop] ||

function buildAstral(slug, isNegated) {
var item = unicode[slug];
var combined = '';
const item = unicode[slug];
let combined = '';
if (item.bmp && !item.isBmpLast) {
combined = '[' + item.bmp + ']' + (item.astral ? '|' : '');
combined = `[${item.bmp}]${item.astral ? '|' : ''}`;
}

@@ -108,3 +107,3 @@ if (item.astral) {

if (item.isBmpLast && item.bmp) {
combined += (item.astral ? '|' : '') + '[' + item.bmp + ']';
combined += `${item.astral ? '|' : ''}[${item.bmp}]`;
}

@@ -114,4 +113,4 @@

return isNegated ?
'(?:(?!' + combined + ')(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|[\0-\uFFFF]))' :
'(?:' + combined + ')';
`(?:(?!${combined})(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|[\0-\uFFFF]))` :
`(?:${combined})`;
}

@@ -121,3 +120,3 @@

function cacheAstral(slug, isNegated) {
var prop = isNegated ? 'a!' : 'a=';
const prop = isNegated ? 'a!' : 'a=';
return (

@@ -139,16 +138,16 @@ unicode[slug][prop] ||

/\\([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';
(match, scope, flags) => {
const ERR_DOUBLE_NEG = 'Invalid double negation ';
const ERR_UNKNOWN_NAME = 'Unknown Unicode token ';
const ERR_UNKNOWN_REF = 'Unicode token missing data ';
const ERR_ASTRAL_ONLY = 'Astral mode required for Unicode token ';
const 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];
let isNegated = match[1] === 'P' || !!match[2];
// Switch from BMP (0-FFFF) to astral (0-10FFFF) mode via flag A
var isAstralMode = flags.indexOf('A') > -1;
const isAstralMode = flags.includes('A');
// Token lookup name. Check `[4]` first to avoid passing `undefined` via `\p{}`
var slug = normalize(match[4] || match[3]);
let slug = normalize(match[4] || match[3]);
// Token data object
var item = unicode[slug];
let item = unicode[slug];

@@ -166,3 +165,3 @@ if (match[1] === 'P' && match[2]) {

if (!unicode.hasOwnProperty(slug)) {
throw new ReferenceError(ERR_UNKNOWN_REF + match[0] + ' -> ' + item.inverseOf);
throw new ReferenceError(`${ERR_UNKNOWN_REF + match[0]} -> ${item.inverseOf}`);
}

@@ -186,3 +185,3 @@ item = unicode[slug];

(isNegated ? cacheInvertedBmp(slug) : item.bmp) :
(isNegated ? '[^' : '[') + item.bmp + ']';
`${(isNegated ? '[^' : '[') + item.bmp}]`;
},

@@ -224,8 +223,8 @@ {

*/
XRegExp.addUnicodeData = function(data) {
var ERR_NO_NAME = 'Unicode token requires name';
var ERR_NO_DATA = 'Unicode token has no character data ';
var item;
XRegExp.addUnicodeData = (data) => {
const ERR_NO_NAME = 'Unicode token requires name';
const ERR_NO_DATA = 'Unicode token has no character data ';
let item;
for (var i = 0; i < data.length; ++i) {
for (let i = 0; i < data.length; ++i) {
item = data[i];

@@ -270,7 +269,6 @@ if (!item.name) {

*/
XRegExp._getUnicodeProperty = function(name) {
var slug = normalize(name);
XRegExp._getUnicodeProperty = (name) => {
const slug = normalize(name);
return unicode[slug];
};
};
/*!
* XRegExp Unicode Blocks 3.2.0
* XRegExp Unicode Blocks 4.0.0
* <xregexp.com>

@@ -8,4 +8,3 @@ * Steven Levithan (c) 2010-2017 MIT License

module.exports = function(XRegExp) {
'use strict';
export default (XRegExp) => {

@@ -1120,3 +1119,2 @@ /**

]);
};
/*!
* XRegExp Unicode Categories 3.2.0
* XRegExp Unicode Categories 4.0.0
* <xregexp.com>

@@ -8,4 +8,3 @@ * Steven Levithan (c) 2010-2017 MIT License

module.exports = function(XRegExp) {
'use strict';
export default (XRegExp) => {

@@ -236,3 +235,2 @@ /**

]);
};
/*!
* XRegExp Unicode Properties 3.2.0
* XRegExp Unicode Properties 4.0.0
* <xregexp.com>

@@ -8,4 +8,3 @@ * Steven Levithan (c) 2012-2017 MIT License

module.exports = function(XRegExp) {
'use strict';
export default (XRegExp) => {

@@ -55,3 +54,3 @@ /**

var unicodeData = [
const unicodeData = [
{

@@ -107,3 +106,2 @@ name: 'ASCII',

XRegExp.addUnicodeData(unicodeData);
};
/*!
* XRegExp Unicode Scripts 3.2.0
* XRegExp Unicode Scripts 4.0.0
* <xregexp.com>

@@ -8,4 +8,3 @@ * Steven Levithan (c) 2010-2017 MIT License

module.exports = function(XRegExp) {
'use strict';
export default (XRegExp) => {

@@ -586,3 +585,2 @@ /**

]);
};

@@ -1,11 +0,19 @@

var XRegExp = require('./xregexp');
import XRegExp from './xregexp';
require('./addons/build')(XRegExp);
require('./addons/matchrecursive')(XRegExp);
require('./addons/unicode-base')(XRegExp);
require('./addons/unicode-blocks')(XRegExp);
require('./addons/unicode-categories')(XRegExp);
require('./addons/unicode-properties')(XRegExp);
require('./addons/unicode-scripts')(XRegExp);
import build from './addons/build';
import matchrecursive from './addons/matchrecursive';
import unicodeBase from './addons/unicode-base';
import unicodeBlocks from './addons/unicode-blocks';
import unicodeCategories from './addons/unicode-categories';
import unicodeProperties from './addons/unicode-properties';
import unicodeScripts from './addons/unicode-scripts';
module.exports = XRegExp;
build(XRegExp);
matchrecursive(XRegExp);
unicodeBase(XRegExp);
unicodeBlocks(XRegExp);
unicodeCategories(XRegExp);
unicodeProperties(XRegExp);
unicodeScripts(XRegExp);
export default XRegExp;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc