diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..cf678794 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +/node_modules +/coverage +/tmp +.DS_Store +.cache +/*.log +.clinic/ diff --git a/lib/specifier.js b/lib/specifier.js index 564a42c1..0c58f7bf 100644 --- a/lib/specifier.js +++ b/lib/specifier.js @@ -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"); @@ -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()) { @@ -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; } diff --git a/lib/version.js b/lib/version.js index c331b400..9fee351e 100644 --- a/lib/version.js +++ b/lib/version.js @@ -1,5 +1,3 @@ -const XRegExp = require("xregexp"); - const VERSION_PATTERN = [ "v?", "(?:", @@ -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; } diff --git a/package.json b/package.json index c4db089d..342dc8f2 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,5 @@ "index.js", "lib", "index.d.ts" - ], - "dependencies": { - "xregexp": "4.4.1" - } + ] } diff --git a/yarn.lock b/yarn.lock index b19d43c7..7e1b8d90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -1200,11 +1192,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== - cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -3092,11 +3079,6 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.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" @@ -3717,13 +3699,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" - y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"