From 9f3612c11284c45f72fc61db09b04850a2dd8316 Mon Sep 17 00:00:00 2001 From: Vadim Budarin Date: Mon, 21 Nov 2022 00:14:31 +0300 Subject: [PATCH] refactor: optimize code --- classes/range.js | 2 +- ranges/to-comparators.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/range.js b/classes/range.js index a791d912..c0da0b8e 100644 --- a/classes/range.js +++ b/classes/range.js @@ -104,7 +104,7 @@ class Range { range = range.replace(re[t.CARETTRIM], caretTrimReplace) // normalize spaces - range = range.split(/\s+/).join(' ') + range = range.replace(/ +/g, ' ') // At this point, the range is completely trimmed and // ready to be split into comparators. diff --git a/ranges/to-comparators.js b/ranges/to-comparators.js index 6c8bc7e6..e2e935ca 100644 --- a/ranges/to-comparators.js +++ b/ranges/to-comparators.js @@ -3,6 +3,6 @@ const Range = require('../classes/range') // Mostly just for testing and legacy API reasons const toComparators = (range, options) => new Range(range, options).set - .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) + .map(comp => comp.map(c => c.value.trim())) module.exports = toComparators