UNPKG

@apollo/core-schema

Version:
87 lines 3.27 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Version = void 0; const recall_1 = __importStar(require("@protoplasm/recall")); class Version { constructor(major, minor) { this.major = major; this.minor = minor; } static parse(input) { if (!input) return null; const match = input.match(this.VERSION_RE); if (!match) return null; return this.canon(+match[1], +match[2]); } static from(input) { if (input instanceof this) return input; if (typeof input === 'string') return this.parse(input); if (Array.isArray(input)) return this.canon(...input); return null; } static canon(major, minor) { return new this(major, minor); } get series() { const { major } = this; return major > 0 ? `${major}.x` : String(this); } toString() { return `v${this.major}.${this.minor}`; } equals(other) { if (!other) return false; return this.major === other.major && this.minor === other.minor; } satisfies(required) { if (!required) return true; const { major, minor } = this; const { major: rMajor, minor: rMinor } = required; return rMajor == major && (major == 0 ? rMinor == minor : rMinor <= minor); } } Version.VERSION_RE = /^v(\d+)\.(\d+)$/; __decorate([ (0, recall_1.use)(recall_1.default) ], Version, "canon", null); exports.Version = Version; exports.default = Version; //# sourceMappingURL=version.js.map