UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

49 lines (43 loc) 1.5 kB
import { assert } from "../../assert.js"; import { UnitMatrix } from "./UnitMatrix.js"; /** * Pairs a {@link UnitMatrix} with the human-readable identifiers that scientists use to talk * about it. * * `name` is the long form ("Volt"), `symbol` is the printable shorthand ("V"), and * `description` is a one-line summary suitable for tooltips or documentation. * * Used by {@link unit_matrix_to_string} as a registry entry: when rendering an arbitrary * unit matrix, the function will prefer to express it as a combination of named units in * the registry rather than as raw base-dimension exponents. */ export class NamedUnit { /** * @param {string} name Long-form name (e.g. `"Volt"`). * @param {string} symbol Printable symbol (e.g. `"V"`). * @param {string} description One-line summary of what the unit measures. * @param {UnitMatrix} unit The dimensional content of this unit. */ constructor(name, symbol, description, unit) { assert.isString(name, 'name'); assert.isString(symbol, 'symbol'); assert.isString(description, 'description'); assert.isInstanceOf(unit, UnitMatrix, 'unit'); /** * @type {string} */ this.name = name; /** * @type {string} */ this.symbol = symbol; /** * @type {string} */ this.description = description; /** * @type {UnitMatrix} */ this.unit = unit; } }