Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove xregexp #137

Merged
merged 6 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/specifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
// for complete details.

const XRegExp = require("xregexp");
const { VERSION_PATTERN, explain: explainVersion } = require("./version");

const Operator = require("./operator");
Expand Down Expand Up @@ -30,7 +29,7 @@ module.exports = {

const isEqualityOperator = (op) => ["==", "!=", "==="].includes(op);

const rangeRegex = new XRegExp("^" + RANGE_PATTERN + "$", "i");
const rangeRegex = new RegExp("^" + RANGE_PATTERN + "$", "i");

function parse(ranges) {
if (!ranges.trim()) {
Expand All @@ -39,8 +38,8 @@ function parse(ranges) {

const specifiers = ranges
.split(",")
.map((range) => XRegExp.exec(range.trim(), rangeRegex))
.map((groups) => {
.map((range) => rangeRegex.exec(range.trim()) || {})
.map(({ groups }) => {
if (!groups) {
return null;
}
Expand Down
8 changes: 3 additions & 5 deletions lib/version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const XRegExp = require("xregexp");

const VERSION_PATTERN = [
"v?",
"(?:",
Expand Down Expand Up @@ -40,20 +38,20 @@ module.exports = {
stringify,
};

const validRegex = new XRegExp("^" + VERSION_PATTERN + "$", "i");
const validRegex = new RegExp("^" + VERSION_PATTERN + "$", "i");

function valid(version) {
return validRegex.test(version) ? version : null;
}

const cleanRegex = new XRegExp("^\\s*" + VERSION_PATTERN + "\\s*$", "i");
const cleanRegex = new RegExp("^\\s*" + VERSION_PATTERN + "\\s*$", "i");
function clean(version) {
return stringify(parse(version, cleanRegex));
}

function parse(version, regex) {
// Validate the version and parse it into pieces
const groups = XRegExp.exec(version, regex || validRegex);
const { groups } = (regex || validRegex).exec(version) || {};
if (!groups) {
return null;
}
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,5 @@
"index.js",
"lib",
"index.d.ts"
],
"dependencies": {
"xregexp": "4.4.1"
}
]
}
25 changes: 0 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,6 @@
dependencies:
"@babel/helper-plugin-utils" "^7.16.7"

"@babel/runtime-corejs3@^7.12.1":
version "7.16.5"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.16.5.tgz#9057d879720c136193f0440bc400088212a74894"
integrity sha512-F1pMwvTiUNSAM8mc45kccMQxj31x3y3P+tA/X8hKNWp3/hUsxdGxZ3D3H8JIkxtfA8qGkaBTKvcmvStaYseAFw==
dependencies:
core-js-pure "^3.19.0"
regenerator-runtime "^0.13.4"

"@babel/template@^7.16.0", "@babel/template@^7.3.3":
version "7.16.0"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.0.tgz#d16a35ebf4cd74e202083356fab21dd89363ddd6"
Expand Down Expand Up @@ -1941,11 +1933,6 @@ convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
dependencies:
safe-buffer "~5.1.1"

core-js-pure@^3.19.0:
version "3.20.1"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.20.1.tgz#f7a2c62f98de83e4da8fca7b78846d3a2f542145"
integrity sha512-yeNNr3L9cEBwNy6vhhIJ0nko7fE7uFO6PgawcacGt2VWep4WqQx0RiqlkgSP7kqUMC1IKdfO9qPeWXcUheHLVQ==

core-util-is@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -5321,11 +5308,6 @@ redeyed@~2.1.0:
dependencies:
esprima "~4.0.0"

regenerator-runtime@^0.13.4:
version "0.13.9"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==

regexpp@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
Expand Down Expand Up @@ -6410,13 +6392,6 @@ xmlchars@^2.2.0:
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==

xregexp@4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.4.1.tgz#c84a88fa79e9ab18ca543959712094492185fe65"
integrity sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==
dependencies:
"@babel/runtime-corejs3" "^7.12.1"

xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
Expand Down