From 804044d74dec28bee748fd519559523c3c586bac Mon Sep 17 00:00:00 2001 From: Amit Sengupta Date: Wed, 7 Sep 2022 14:32:35 +0530 Subject: [PATCH] Update range.js Update range.js comments to clarify the caret exaples Caret (^) - does not modify the left-most non-zero element in the M.m.p-e. Tilde (~) - does not modify M and m. hence, ^0.0.1-1 matches 0.0.1-5 however, ~0.0.1-1 matches 0.0.5 which might be counterintuitive and hence adding this example explicitly. --- classes/range.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/range.js b/classes/range.js index 7dc24bc7..a791d912 100644 --- a/classes/range.js +++ b/classes/range.js @@ -252,6 +252,7 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 +// ~0.0.1 --> >=0.0.1 <0.1.0-0 const replaceTildes = (comp, options) => comp.trim().split(/\s+/).map((c) => { return replaceTilde(c, options) @@ -291,6 +292,8 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 const replaceCarets = (comp, options) => comp.trim().split(/\s+/).map((c) => { return replaceCaret(c, options)