UNPKG

qasm-ts

Version:

QASM, the low-level programming language for quantum circuit specification, implemented in TypeScript.

58 lines (57 loc) 2.16 kB
"use strict"; /** * OpenQASM version detection and management utilities * * Handles version detection from QASM source code and provides utilities * for working with different OpenQASM versions. Supports automatic version * detection from OPENQASM statements and manual version specification. * * @module Version Management * * @example Version detection * ```typescript * const version = new OpenQASMVersion(3, 0); * console.log(version.toString()); // "3.0" * console.log(version.isVersion3()); // true * ``` */ Object.defineProperty(exports, "__esModule", { value: true }); exports.OpenQASMVersion = exports.OpenQASMMajorVersion = void 0; /** Enum representing the major OpenQASM versions. */ var OpenQASMMajorVersion; (function (OpenQASMMajorVersion) { OpenQASMMajorVersion[OpenQASMMajorVersion["Version2"] = 2] = "Version2"; OpenQASMMajorVersion[OpenQASMMajorVersion["Version3"] = 3] = "Version3"; })(OpenQASMMajorVersion || (exports.OpenQASMMajorVersion = OpenQASMMajorVersion = {})); /** Class representing the OpenQASM version. */ var OpenQASMVersion = /** @class */ (function () { /** * Creates an OpenQASMVersion instance. * @param major - The OpenQASM major version. (optional) * @param minor - The OpenQASM minor version (optional) */ function OpenQASMVersion(major, minor) { this.major = major ? major : OpenQASMMajorVersion.Version3; this.minor = minor ? minor : 0; } /** Returns the version as a formatted string. */ OpenQASMVersion.prototype.toString = function () { return "".concat(this.major, ".").concat(this.minor); }; /** Returns whether the version is 3.x */ OpenQASMVersion.prototype.isVersion3 = function () { if (this.major === OpenQASMMajorVersion.Version3) { return true; } return false; }; /** Returns whether the version is 2.x */ OpenQASMVersion.prototype.isVersion2 = function () { if (this.major === OpenQASMMajorVersion.Version2) { return true; } return false; }; return OpenQASMVersion; }()); exports.OpenQASMVersion = OpenQASMVersion;