MCPcopy
hub / github.com/redis/node-redis / parseVersionNumber

Method parseVersionNumber

packages/test-utils/lib/index.ts:201–221  ·  view source on GitHub ↗
(version: string)

Source from the content-addressed store, hash-verified

199
200export default class TestUtils {
201 static parseVersionNumber(version: string): Array<number> {
202 if (version === 'latest' || version === 'edge') return [Infinity];
203
204
205 // Match complete version number patterns
206 const versionMatch = version.match(/(^|-)\d+(\.\d+)*($|-)/);
207 if (!versionMatch) {
208 throw new TypeError(`${version} is not a valid redis version`);
209 }
210
211 // Extract just the numbers and dots between first and last dash (or start/end)
212 const versionNumbers = versionMatch[0].replace(/^-|-$/g, '');
213
214 return versionNumbers.split('.').map(x => {
215 const value = Number(x);
216 if (Number.isNaN(value)) {
217 throw new TypeError(`${version} is not a valid redis version`);
218 }
219 return value;
220 });
221 }
222 static #getVersion(
223 tagArgumentName: string,
224 versionArgumentName: string | undefined,

Callers 2

#getVersionMethod · 0.80
index.spec.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected