apple-version-history
Version:
List of released Apple operating system versions and builds.
53 lines (52 loc) • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.pickJson = pickJson;
exports.versionNameWithoutSuffix = versionNameWithoutSuffix;
exports.versionNumberWithoutPatch = versionNumberWithoutPatch;
exports.addMinorZero = addMinorZero;
exports.hasPatch = hasPatch;
const ios_version_history_1 = require("./ios-version-history");
const macos_version_history_1 = require("./macos-version-history");
const tvos_version_history_1 = require("./tvos-version-history");
const watchos_version_history_1 = require("./watchos-version-history");
function pickJson(os) {
switch (os) {
case 'ios':
return ios_version_history_1.default;
case 'macos':
return macos_version_history_1.default;
case 'tvos':
return tvos_version_history_1.default;
case 'watchos':
return watchos_version_history_1.default;
default:
throw `Unexpected os value: ${os}`;
}
}
/**
* Removes "1.0.x" part from "iPhone OS 1.0.x".
*/
function versionNameWithoutSuffix(versionName) {
const split = versionName.split(' ');
return split.slice(0, split.length - 1).join(' ');
}
/**
* Removes ".2" part from "1.0.2".
*/
function versionNumberWithoutPatch(versionNumber) {
return versionNumber.split('.').slice(0, 2).join('.');
}
/**
* Adds minor ".0" part if it's missing.
* e.g. `15` becomes `15.0`.
*/
function addMinorZero(version) {
return version.includes('.') ? version : `${version}.0`;
}
/**
* Checks whether the version-number has patch part or not.
* e.g. `10.0.1` has patch, and `10.0` has not.
*/
function hasPatch(versionNumber) {
return /^\d+\.\d+\.\d+$/.test(versionNumber);
}