diff --git a/classes/range.js b/classes/range.js index a791d912..d9e866de 100644 --- a/classes/range.js +++ b/classes/range.js @@ -81,8 +81,10 @@ class Range { // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) if (cached) { return cached @@ -190,6 +192,7 @@ class Range { return false } } + module.exports = Range const LRU = require('lru-cache') @@ -206,6 +209,7 @@ const { tildeTrimReplace, caretTrimReplace, } = require('../internal/re') +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants') const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' diff --git a/internal/constants.js b/internal/constants.js index 4f0de59b..9e19d626 100644 --- a/internal/constants.js +++ b/internal/constants.js @@ -14,4 +14,7 @@ module.exports = { MAX_LENGTH, MAX_SAFE_INTEGER, MAX_SAFE_COMPONENT_LENGTH, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, + FLAG_RTL: 0b100, }