UNPKG

@teraflop/api

Version:

Teraflop game engine WebAssembly scripting API

38 lines (37 loc) 1.73 kB
"use strict"; // Plugin interface Object.defineProperty(exports, "__esModule", { value: true }); exports.makeVersion = exports.VersionMeta = void 0; var VersionMeta; (function (VersionMeta) { VersionMeta[VersionMeta["Release"] = 0] = "Release"; VersionMeta[VersionMeta["ReleaseCandidate"] = 1] = "ReleaseCandidate"; VersionMeta[VersionMeta["PreRelease"] = 2] = "PreRelease"; VersionMeta[VersionMeta["Beta"] = 3] = "Beta"; VersionMeta[VersionMeta["Alpha"] = 4] = "Alpha"; VersionMeta[VersionMeta["PreAlpha"] = 5] = "PreAlpha"; VersionMeta[VersionMeta["MAX"] = u8.MAX_VALUE] = "MAX"; })(VersionMeta = exports.VersionMeta || (exports.VersionMeta = {})); /** * Pack a Semantic Version into a 32-bit bitfield. * @param major Incompatible API changes * @param minor Added functionality in a backwards compatible manner * @param patch Backwards compatible bug fixes * @param meta Additional label for pre-release and build metadata * * **Bitfield** * * | major | minor | patch | meta | * | ----------- | ----------- | ----------- | ----------- | * | `0000 0000` | `0000 0000` | `0000 0000` | `0000 0000` | * * @see https://semver.org */ function makeVersion(major, minor, patch, meta = VersionMeta.Release) { assert(major >= 0 && major <= u8.MAX_VALUE, "Major version component is out of bounds"); assert(minor >= 0 && minor <= u8.MAX_VALUE, "Minor version component is out of bounds"); assert(patch >= 0 && patch <= u8.MAX_VALUE, "Patch version component is out of bounds"); assert(meta >= 0 && meta <= u8.MAX_VALUE, "Version metadata is out of bounds"); return (major << 24) | (minor << 16) | (patch << 8) | meta; } exports.makeVersion = makeVersion;