regex-to-strings
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -10,2 +10,4 @@ "use strict"; | ||
var _constants = require("../constants"); | ||
var _Expansion = _interopRequireDefault(require("../Expansion")); | ||
@@ -36,4 +38,3 @@ | ||
var allCharOptions = ' \t\r\n' + 'abcdefghijklmnopqrstuvwxyz' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + '0123456789' + '~`!@#$%^&*()-_=+<,>.?/[]{}|\\:;"\''; | ||
var allCodePointOptions = allCharOptions.split('').map(function (_char) { | ||
var allCodePointOptions = _constants.Chars.all.map(function (_char) { | ||
return _char.charCodeAt(0); | ||
@@ -49,2 +50,3 @@ }); | ||
function expandCharacterClass(node) { | ||
@@ -51,0 +53,0 @@ var _this = this; |
@@ -10,2 +10,4 @@ "use strict"; | ||
var _constants = require("../constants"); | ||
var Guards = _interopRequireWildcard(require("../types/regexp-tree-guards")); | ||
@@ -66,10 +68,19 @@ | ||
}; | ||
var optionsAlpha = [(0, _utils.createClassRange)('a', 'z'), (0, _utils.createClassRange)('A', 'Z')]; | ||
var optionsDigit = (0, _utils.createClassRange)('0', '9'); | ||
var optionUnderscore = (0, _utils.createEscapedSimpleChar)('_'); | ||
var optionsWhitespaceNoBreak = (0, _utils.createSimpleChars)(' \t'); | ||
var optionsWhitespace = [].concat(_toConsumableArray(optionsWhitespaceNoBreak), _toConsumableArray((0, _utils.createSimpleChars)('\r\n'))); | ||
var optionsOther = [].concat(_toConsumableArray((0, _utils.createSimpleChars)('~`!@#$%^&*()=+<,>.?/[{}|:;"\'')), [(0, _utils.createEscapedSimpleChar)(']'), (0, _utils.createEscapedSimpleChar)('-'), (0, _utils.createEscapedSimpleChar)('\\')]); | ||
var optionsNewLine = (0, _utils.createSimpleChar)('\n'); | ||
var optionsAlpha = _constants.Chars.basicAlpha.map(_utils.createSimpleChar); | ||
var optionsDigit = _constants.Chars.digits.map(_utils.createSimpleChar); | ||
var optionsWhitespace = _constants.Chars.whitespace.map(_utils.createSimpleChar); | ||
var needEscape = [']', '-', '\\']; | ||
var noEscape = _constants.Chars.basicSpecial.filter(function (c) { | ||
return !needEscape.includes(c); | ||
}); | ||
var optionsOther = [].concat(_toConsumableArray(noEscape.map(_utils.createSimpleChar)), _toConsumableArray(needEscape.map(_utils.createEscapedSimpleChar))); | ||
var optionsExtended = _constants.Chars.extended.map(_utils.createSimpleChar); | ||
function getMetaCharExpressions(metaChar, regExpFlags) { | ||
@@ -79,17 +90,24 @@ switch (metaChar.value) { | ||
{ | ||
var dotAllOptions = regExpFlags.includes('s') ? [optionsNewLine] : []; | ||
return [].concat(optionsAlpha, [optionsDigit], _toConsumableArray(optionsWhitespaceNoBreak), _toConsumableArray(optionsOther), [optionUnderscore], dotAllOptions); | ||
var optionsNewLine = (0, _utils.createSimpleChar)('\n'); | ||
var optionsDotAll = regExpFlags.includes('s') ? [optionsNewLine] : []; | ||
var whitespaceNoBreaks = _constants.Chars.whitespace.filter(function (c) { | ||
return !'\r\n'.includes(c); | ||
}); | ||
var optionsWhitespaceNoBreak = whitespaceNoBreaks.map(_utils.createSimpleChar); | ||
return [].concat(_toConsumableArray(optionsAlpha), _toConsumableArray(optionsDigit), _toConsumableArray(optionsWhitespaceNoBreak), _toConsumableArray(optionsOther), _toConsumableArray(optionsExtended), optionsDotAll); | ||
} | ||
case '\\w': | ||
return [].concat(optionsAlpha, [optionsDigit, optionUnderscore]); | ||
return [].concat(_toConsumableArray(optionsAlpha), _toConsumableArray(optionsDigit)); | ||
case '\\W': | ||
return [].concat(_toConsumableArray(optionsWhitespace), _toConsumableArray(optionsOther)); | ||
return [].concat(_toConsumableArray(optionsWhitespace), _toConsumableArray(optionsOther), _toConsumableArray(optionsExtended)); | ||
case '\\d': | ||
return [optionsDigit]; | ||
return optionsDigit; | ||
case '\\D': | ||
return [].concat(optionsAlpha, _toConsumableArray(optionsWhitespace), _toConsumableArray(optionsOther), [optionUnderscore]); | ||
return [].concat(_toConsumableArray(optionsAlpha), _toConsumableArray(optionsWhitespace), _toConsumableArray(optionsOther), _toConsumableArray(optionsExtended)); | ||
@@ -100,3 +118,3 @@ case '\\s': | ||
case '\\S': | ||
return [].concat(optionsAlpha, [optionsDigit], _toConsumableArray(optionsOther), [optionUnderscore]); | ||
return [].concat(_toConsumableArray(optionsAlpha), _toConsumableArray(optionsDigit), _toConsumableArray(optionsOther), _toConsumableArray(optionsExtended)); | ||
@@ -103,0 +121,0 @@ default: |
@@ -1,5 +0,3 @@ | ||
import { ClassRange, SimpleChar } from 'regexp-tree/ast'; | ||
import { SimpleChar } from 'regexp-tree/ast'; | ||
export declare function createSimpleChar(value: string): SimpleChar; | ||
export declare function createEscapedSimpleChar(value: string): SimpleChar; | ||
export declare function createSimpleChars(values: string): SimpleChar[]; | ||
export declare function createClassRange(from: string, to: string): ClassRange; |
@@ -8,4 +8,2 @@ "use strict"; | ||
exports.createEscapedSimpleChar = createEscapedSimpleChar; | ||
exports.createSimpleChars = createSimpleChars; | ||
exports.createClassRange = createClassRange; | ||
@@ -33,14 +31,2 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
}); | ||
} | ||
function createSimpleChars(values) { | ||
return values.split('').map(createSimpleChar); | ||
} | ||
function createClassRange(from, to) { | ||
return { | ||
from: createSimpleChar(from), | ||
to: createSimpleChar(to), | ||
type: 'ClassRange' | ||
}; | ||
} |
{ | ||
"name": "regex-to-strings", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
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
86804
48
1462