(str)
| 266 | * @returns {SemVerRange} |
| 267 | */ |
| 268 | const parseRange = (str) => { |
| 269 | // range ::= hyphen | simple ( ' ' ( ' ' ) * simple ) * | '' |
| 270 | // hyphen ::= partial ( ' ' ) * ' - ' ( ' ' ) * partial |
| 271 | const items = str.split(/\s+-\s+/); |
| 272 | |
| 273 | if (items.length === 1) { |
| 274 | str = str.trim(); |
| 275 | |
| 276 | /** @type {SemVerRangeItem[][]} */ |
| 277 | const items = []; |
| 278 | const r = /[-0-9A-Za-z]\s+/g; |
| 279 | var start = 0; |
| 280 | /** @type {RegExpExecArray | null} */ |
| 281 | var match; |
| 282 | while ((match = r.exec(str))) { |
| 283 | const end = match.index + 1; |
| 284 | items.push( |
| 285 | /** @type {SemVerRangeItem[]} */ |
| 286 | (parseSimple(str.slice(start, end).trim())) |
| 287 | ); |
| 288 | start = end; |
| 289 | } |
| 290 | items.push( |
| 291 | /** @type {SemVerRangeItem[]} */ |
| 292 | (parseSimple(str.slice(start).trim())) |
| 293 | ); |
| 294 | return combine(items, 2); |
| 295 | } |
| 296 | |
| 297 | const a = parsePartial(items[0]); |
| 298 | const b = parsePartial(items[1]); |
| 299 | // >=a <=b => and( >=a, or( <b, =b ) ) => >=a, <b, =b, or, and |
| 300 | // eslint-disable-next-line no-sparse-arrays |
| 301 | return [, toFixed(b), negate(b), 1, a, 2]; |
| 302 | }; |
| 303 | |
| 304 | /** |
| 305 | * Returns the sem ver range. |
no test coverage detected