/** * @see {@link https://semver.org} * @class Keppo * @private {number} major * @private {number} minor * @private {number} patch * @private {boolean} strict * @private {string} label */ export class Keppo { /** * @static * A static method that checks whether the provided String is a valid SemVer version number. Useful for checking whether a version is valid before calling {@link setVersion()}. * @param {string} version A String representing a SemVer version number * @param {boolean} [isStrict=true] A Boolean representing whether the strict mode is enabled, defaults to **true** and is not inferred from this instance's `strict` property. * @returns {boolean} */ static isValid(version: string, isStrict?: boolean | undefined): boolean; /** * Creates a Keppo instance. * @constructor * @param {number|string} major Major version number or a valid SemVer version string - other parameters are ignored in this case. * @param {number} [minor=0] Minor version number. * @param {number} [patch=0] Patch version number. * @param {boolean} [strict=true] Strict mode. * @param {string} [label=''] Label for the version, no need to prefix with a dash. * @throws {TypeError|Error} Throws an exception if any of the passed parameters are not valid. */ constructor(major?: number | string, minor?: number | undefined, patch?: number | undefined, strict?: boolean | undefined, label?: string | undefined); strict: boolean; patch: number; minor: number; major: number; label: string; /** * Parses the provided string as a SemVer version. * * See also {@link setVersion()}. * @param {string} version A valid SemVer version represented as a string, e.g. `"1.2.3"`, `"v1.5.3"`, `"2.3.4-alpha"`, `"v2.4.6-beta"`. * @throws {TypeError|Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} Returns a new instance of `Keppo` with the parsed version. */ parse(version: string): Keppo; /** * Sets the strict mode for the SemVer version, i.e. allow `v` as a prefix for SemVer, e.g. `v1.0.0`. By default, strict mode is `true`. * @param {boolean} [isStrict=true] * @returns {Keppo} */ isStrict(isStrict?: boolean | undefined): Keppo; /** * Increases the major version number for the provided value. * @param {number} [major=1] The major version number to increase by, defaults to `1`. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ increaseMajor(major?: number | undefined): Keppo; /** * Increases the minor version number for the provided value. * @param {number} [minor=1] The minor version number to increase by, defaults to `1`. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ increaseMinor(minor?: number | undefined): Keppo; /** * Increases the patch version number for the provided value. * @param {number} [patch=1] The patch version number to increase by, defaults to `1`. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ increasePatch(patch?: number | undefined): Keppo; /** * Decreases the major version number for the provided value. * @param {number} [major=1] The major version number to decrease by, defaults to `1`. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ decreaseMajor(major?: number | undefined): Keppo; /** * Decreases the minor version number for the provided value. * @param {number} [minor=1] The minor version number to decrease by, defaults to `1`. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ decreaseMinor(minor?: number | undefined): Keppo; /** * Decrease the patch version number for the provided value. * @param {number} [patch=1] The patch version number to decrease by, defaults to `1`. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ decreasePatch(patch?: number | undefined): Keppo; /** * Sets the major version number for the current Keppo instance. * @param {number|string} major The major version number, either as a number or as a string. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ setMajor(major: number | string): Keppo; /** * Sets the minor version number for the current Keppo instance. * @param {number|string} minor The minor version number, either as a number or as a string. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ setMinor(minor: number | string): Keppo; /** * Sets the patch version number for the current Keppo instance. * @param {number|string} patch The patch version number, either as a number or as a string. * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ setPatch(patch: number | string): Keppo; /** * Sets the version label for the current Keppo instance. No need to prefix with a dash "`-`", i.e. "`alpha`" and its output would be `0.1.0-alpha`. * @param {string} label * @throws {Error} Throws an exception if the passed parameter is not valid. * @returns {Keppo} */ setLabel(label: string): Keppo; /** * Compares the current `Keppo` SemVer-compatible version with a provided one. The passed argument can either be another instance of `Keppo` or a valid SemVer string. * @param {Keppo|string} version * @throws {Error} Throws an exception if the passed parameter is not valid or the passed parameter is not a valid SemVer version. * @returns {Number} A value defined as: * - `-1` if the current instance version is less than the provided version, * - `0` if the compared versions are equal, * - `1` if the current instance version is greater than the provided version. */ compare(version: Keppo | string): number; /** * Prints to console the String representation of the current `Keppo` object. * @returns {void} */ output(): void; /** * Sets the current Keppo version. The passed value must be a valid SemVer string. This will replace all the previous version information. * * See also {@link parse()}. * @param {string} version * @returns {Keppo} * @throws {TypeError|Error} Throws an exception if the passed parameter is not valid or the passed parameter is not a valid SemVer version. */ setVersion(version: string): Keppo; /** * Formats the current `Keppo` object as a String. * @returns {string} */ toString(): string; /** * Checks whether this instance's major version can be safely increased by the given value. * * Read more about Integer safety on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger MDN}. * @param {number} [major=1] The value to increase by * @returns {boolean} */ canIncreaseMajor(major?: number | undefined): boolean; /** * Checks whether a minor version can be safely increased by the given value. * * Read more about Integer safety on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger MDN}. * @param {number} [minor=1] The value to increase by * @returns {boolean} */ canIncreaseMinor(minor?: number | undefined): boolean; /** * Checks whether a patch version can be safely increased by the given value. * * Read more about Integer safety on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger MDN}. * @param {number} [patch=1] The value to increase by * @returns {boolean} */ canIncreasePatch(patch?: number | undefined): boolean; /** * Returns the maximum possible value that can be used to increase the major version number. * * Read more about Integer safety on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger MDN}. * @returns {number} */ maxIncreaseMajor(): number; /** * Returns the maximum possible value that can be used to increase the minor version number. * * Read more about Integer safety on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger MDN}. * @returns {number} */ maxIncreaseMinor(): number; /** * Returns the maximum possible value that can be used to increase the patch version number. * * Read more about Integer safety on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger MDN}. * @returns {number} */ maxIncreasePatch(): number; }