@@ -4,7 +4,7 @@ const SPEC_VERSION_PATTERN = /^\d+\.\d+$/;
44const SUPPORTED_VERSIONS = [
55 "0.1" , "1.0" , "1.1" ,
66 "2.0" , "2.1" , "2.2" , "2.3" , "2.4" , "2.5" , "2.6" ,
7- "3.0"
7+ "3.0" , "3.1"
88] ;
99
1010/**
@@ -63,8 +63,8 @@ class SpecificationVersion {
6363 * Test whether the instance's Specification Version falls into the provided range
6464 *
6565 * @public
66- @param {string } range [Semver]{@link https://www.npmjs.com/package/semver}-style version range,
67- for example <code>2.2 - 2.4</code>
66+ * @param {string } range [Semver]{@link https://www.npmjs.com/package/semver}-style version range,
67+ * for example <code>2.2 - 2.4</code> or <code>=3.0 </code>
6868 * @returns {boolean } True if the instance's Specification Version falls into the provided range
6969 */
7070 satisfies ( range ) {
@@ -263,6 +263,22 @@ for example <code>2.2 - 2.4</code>
263263 const comparator = new SpecificationVersion ( specVersion ) ;
264264 return comparator . neq ( testVersion ) ;
265265 }
266+
267+ /**
268+ * Create an array of Specification Versions that match with the provided range. This is mainly used
269+ * for testing purposes. I.e. to execute identical tests for a range of specification versions.
270+ *
271+ * @public
272+ * @param {string } range [Semver]{@link https://www.npmjs.com/package/semver}-style version range,
273+ * for example <code>2.2 - 2.4</code> or <code>=3.0</code>
274+ * @returns {string[] } Array of versions that match the specified range
275+ */
276+ static getVersionsForRange ( range ) {
277+ return SUPPORTED_VERSIONS . filter ( ( specVersion ) => {
278+ const comparator = new SpecificationVersion ( specVersion ) ;
279+ return comparator . satisfies ( range ) ;
280+ } ) ;
281+ }
266282}
267283
268284function getUnsupportedSpecVersionMessage ( specVersion ) {
0 commit comments