MCPcopy
hub / github.com/sindresorhus/np / #trySetVersion

Method #trySetVersion

source/version.js:48–54  ·  view source on GitHub ↗

Sets `this.#version` to the given version. @param {string} version @throws If `version` is an invalid `SemVer` version.

(version)

Source from the content-addressed store, hash-verified

46 @throws If `version` is an invalid `SemVer` version.
47 */
48 #trySetVersion(version) {
49 this.#version = semver.parse(version);
50
51 if (this.#version === null) {
52 throw new Error(`Version ${version} should be a valid SemVer version.`);
53 }
54 }
55
56 /**
57 @param {string} version - A valid `SemVer` version.

Callers 2

constructorMethod · 0.95
setFromMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected