@qudtlib/core
Advanced tools
Comparing version 5.0.1 to 6.0.0
import { Unit } from "./unit.js"; | ||
export declare type UnitOrExponent = Unit | number; | ||
export declare type ExponentUnitPairs = UnitOrExponent[]; | ||
export type UnitOrExponent = Unit | number; | ||
export type ExponentUnitPairs = UnitOrExponent[]; | ||
export interface SupportsEquals<Type> { | ||
@@ -5,0 +5,0 @@ equals(other?: Type): boolean; |
@@ -10,2 +10,3 @@ "use strict"; | ||
this.broaderQuantityKindIris = []; | ||
this.exactMatchIris = []; | ||
this.dimensionVectorIri = dimensionVector; | ||
@@ -20,2 +21,5 @@ this.symbol = symbol; | ||
} | ||
getIriLocalname() { | ||
return (0, utils_js_1.getLastIriElement)(this.iri); | ||
} | ||
addLabel(label) { | ||
@@ -37,2 +41,5 @@ this.labels.push(label); | ||
} | ||
addExactMatchIri(exactMatch) { | ||
this.exactMatchIris.push(exactMatch); | ||
} | ||
equals(other) { | ||
@@ -39,0 +46,0 @@ return !!other && this.iri === other.iri; |
@@ -121,2 +121,12 @@ "use strict"; | ||
} | ||
static isBroaderQuantityKind(suspectedBroader, quantityKind) { | ||
const broader = quantityKind.broaderQuantityKindIris; | ||
if (broader.length === 0) { | ||
return false; | ||
} | ||
if (broader.includes(suspectedBroader.iri)) { | ||
return true; | ||
} | ||
return broader.some((b) => Qudt.isBroaderQuantityKind(Qudt.quantityKindRequired(b), suspectedBroader)); | ||
} | ||
static prefixFromLabelRequired(label) { | ||
@@ -123,0 +133,0 @@ const match = this.prefixFromLabel(label); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SystemOfUnits = exports.Namespace = exports.QudtlibConfig = exports.config = exports.Qudt = exports.LangString = exports.QuantityValue = exports.AssignmentProblem = exports.FactorUnits = exports.FactorUnit = exports.DerivedUnitSearchMode = exports.Prefix = exports.QuantityKind = exports.Unit = exports.Decimal = void 0; | ||
exports.QudtNamespaces = exports.SystemOfUnits = exports.Namespace = exports.QudtlibConfig = exports.config = exports.Qudt = exports.LangString = exports.QuantityValue = exports.AssignmentProblem = exports.FactorUnits = exports.FactorUnit = exports.DerivedUnitSearchMode = exports.Prefix = exports.QuantityKind = exports.Unit = exports.Decimal = void 0; | ||
const decimal_js_1 = require("decimal.js"); | ||
@@ -28,6 +28,8 @@ Object.defineProperty(exports, "Decimal", { enumerable: true, get: function () { return decimal_js_1.Decimal; } }); | ||
Object.defineProperty(exports, "SystemOfUnits", { enumerable: true, get: function () { return systemOfUnits_js_1.SystemOfUnits; } }); | ||
const qudtNamespaces_js_1 = require("./qudtNamespaces.js"); | ||
Object.defineProperty(exports, "QudtNamespaces", { enumerable: true, get: function () { return qudtNamespaces_js_1.QudtNamespaces; } }); | ||
const qudt_js_1 = require("./qudt.js"); | ||
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return qudt_js_1.config; } }); | ||
Object.defineProperty(exports, "Qudt", { enumerable: true, get: function () { return qudt_js_1.Qudt; } }); | ||
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return qudt_js_1.config; } }); | ||
Object.defineProperty(exports, "QudtlibConfig", { enumerable: true, get: function () { return qudt_js_1.QudtlibConfig; } }); | ||
//# sourceMappingURL=qudtlib.js.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
class Unit { | ||
constructor(iri, quantityKindIris, dimensionVectorIri, conversionMultiplier, conversionOffset, prefixIri, scalingOfIri, scalingOf, symbol, labels, currencyCode, currencyNumber, unitOfSystemIris) { | ||
constructor(iri, quantityKindIris, exactMatchIris, dimensionVectorIri, conversionMultiplier, conversionOffset, prefixIri, scalingOfIri, scalingOf, symbol, labels, currencyCode, currencyNumber, unitOfSystemIris) { | ||
this.quantityKinds = []; | ||
@@ -34,2 +34,8 @@ this.factorUnits = []; | ||
} | ||
if (typeof exactMatchIris === "undefined") { | ||
this.exactMatchIris = []; | ||
} | ||
else { | ||
this.exactMatchIris = exactMatchIris; | ||
} | ||
if (typeof labels === "undefined") { | ||
@@ -62,2 +68,5 @@ this.labels = []; | ||
} | ||
getIriLocalname() { | ||
return (0, utils_js_1.getLastIriElement)(this.iri); | ||
} | ||
matchesFactorUnitSpec(...factorUnitSpec) { | ||
@@ -161,2 +170,5 @@ return this.matches(factorUnits_js_1.FactorUnits.ofFactorUnitSpec(...factorUnitSpec)); | ||
} | ||
addExactMatchIri(exactMatchIri) { | ||
this.exactMatchIris.push(exactMatchIri); | ||
} | ||
hasLabel(label) { | ||
@@ -163,0 +175,0 @@ return this.labels.some((l) => label === l.text); |
@@ -7,2 +7,3 @@ import { getLastIriElement } from "./utils.js"; | ||
this.broaderQuantityKindIris = []; | ||
this.exactMatchIris = []; | ||
this.dimensionVectorIri = dimensionVector; | ||
@@ -17,2 +18,5 @@ this.symbol = symbol; | ||
} | ||
getIriLocalname() { | ||
return getLastIriElement(this.iri); | ||
} | ||
addLabel(label) { | ||
@@ -34,2 +38,5 @@ this.labels.push(label); | ||
} | ||
addExactMatchIri(exactMatch) { | ||
this.exactMatchIris.push(exactMatch); | ||
} | ||
equals(other) { | ||
@@ -36,0 +43,0 @@ return !!other && this.iri === other.iri; |
@@ -117,2 +117,12 @@ import { Unit } from "./unit.js"; | ||
} | ||
static isBroaderQuantityKind(suspectedBroader, quantityKind) { | ||
const broader = quantityKind.broaderQuantityKindIris; | ||
if (broader.length === 0) { | ||
return false; | ||
} | ||
if (broader.includes(suspectedBroader.iri)) { | ||
return true; | ||
} | ||
return broader.some((b) => Qudt.isBroaderQuantityKind(Qudt.quantityKindRequired(b), suspectedBroader)); | ||
} | ||
static prefixFromLabelRequired(label) { | ||
@@ -119,0 +129,0 @@ const match = this.prefixFromLabel(label); |
@@ -13,4 +13,5 @@ import { Decimal } from "decimal.js"; | ||
import { SystemOfUnits } from "./systemOfUnits.js"; | ||
import { Qudt, config, QudtlibConfig } from "./qudt.js"; | ||
export { Decimal, Unit, QuantityKind, Prefix, DerivedUnitSearchMode, FactorUnit, FactorUnits, AssignmentProblem, QuantityValue, LangString, Qudt, config, QudtlibConfig, Namespace, SystemOfUnits, }; | ||
import { QudtNamespaces } from "./qudtNamespaces.js"; | ||
import { config, Qudt, QudtlibConfig } from "./qudt.js"; | ||
export { Decimal, Unit, QuantityKind, Prefix, DerivedUnitSearchMode, FactorUnit, FactorUnits, AssignmentProblem, QuantityValue, LangString, Qudt, config, QudtlibConfig, Namespace, SystemOfUnits, QudtNamespaces, }; | ||
//# sourceMappingURL=qudtlib.js.map |
@@ -6,3 +6,3 @@ import { FactorUnit } from "./factorUnit.js"; | ||
export class Unit { | ||
constructor(iri, quantityKindIris, dimensionVectorIri, conversionMultiplier, conversionOffset, prefixIri, scalingOfIri, scalingOf, symbol, labels, currencyCode, currencyNumber, unitOfSystemIris) { | ||
constructor(iri, quantityKindIris, exactMatchIris, dimensionVectorIri, conversionMultiplier, conversionOffset, prefixIri, scalingOfIri, scalingOf, symbol, labels, currencyCode, currencyNumber, unitOfSystemIris) { | ||
this.quantityKinds = []; | ||
@@ -31,2 +31,8 @@ this.factorUnits = []; | ||
} | ||
if (typeof exactMatchIris === "undefined") { | ||
this.exactMatchIris = []; | ||
} | ||
else { | ||
this.exactMatchIris = exactMatchIris; | ||
} | ||
if (typeof labels === "undefined") { | ||
@@ -59,2 +65,5 @@ this.labels = []; | ||
} | ||
getIriLocalname() { | ||
return getLastIriElement(this.iri); | ||
} | ||
matchesFactorUnitSpec(...factorUnitSpec) { | ||
@@ -158,2 +167,5 @@ return this.matches(FactorUnits.ofFactorUnitSpec(...factorUnitSpec)); | ||
} | ||
addExactMatchIri(exactMatchIri) { | ||
this.exactMatchIris.push(exactMatchIri); | ||
} | ||
hasLabel(label) { | ||
@@ -160,0 +172,0 @@ return this.labels.some((l) => label === l.text); |
@@ -10,3 +10,5 @@ import { SupportsEquals } from "./baseTypes.js"; | ||
readonly symbol?: string; | ||
readonly exactMatchIris: string[]; | ||
constructor(iri: string, dimensionVector?: string, symbol?: string, labels?: LangString[]); | ||
getIriLocalname(): string; | ||
addLabel(label: LangString): void; | ||
@@ -17,2 +19,3 @@ hasLabel(label: string): boolean; | ||
addBroaderQuantityKindIri(quantityKind: string): void; | ||
addExactMatchIri(exactMatch: string): void; | ||
equals(other?: QuantityKind): boolean; | ||
@@ -19,0 +22,0 @@ toString(): string; |
@@ -8,3 +8,2 @@ import { Unit } from "./unit.js"; | ||
import { QuantityValue } from "./quantityValue.js"; | ||
import { Namespace } from "./namespace.js"; | ||
import { Decimal } from "decimal.js"; | ||
@@ -22,8 +21,8 @@ import { SystemOfUnits } from "./systemOfUnits.js"; | ||
static NAMESPACES: Readonly<{ | ||
qudt: Namespace; | ||
quantityKind: Namespace; | ||
unit: Namespace; | ||
currency: Namespace; | ||
prefix: Namespace; | ||
systemOfUnits: Namespace; | ||
qudt: import("./namespace.js").Namespace; | ||
quantityKind: import("./namespace.js").Namespace; | ||
unit: import("./namespace.js").Namespace; | ||
currency: import("./namespace.js").Namespace; | ||
prefix: import("./namespace.js").Namespace; | ||
systemOfUnits: import("./namespace.js").Namespace; | ||
}>; | ||
@@ -68,2 +67,3 @@ /** | ||
static quantityKindsBroad(unit: Unit): QuantityKind[]; | ||
static isBroaderQuantityKind(suspectedBroader: QuantityKind, quantityKind: QuantityKind): boolean; | ||
static prefixFromLabelRequired(label: string): Prefix; | ||
@@ -70,0 +70,0 @@ static prefixFromLabel(label: string): Prefix | undefined; |
@@ -13,4 +13,5 @@ import { Decimal } from "decimal.js"; | ||
import { SystemOfUnits } from "./systemOfUnits.js"; | ||
import { Qudt, config, QudtlibConfig } from "./qudt.js"; | ||
export { Decimal, Unit, QuantityKind, Prefix, DerivedUnitSearchMode, FactorUnit, FactorUnits, AssignmentProblem, QuantityValue, LangString, Qudt, config, QudtlibConfig, Namespace, SystemOfUnits, }; | ||
import { QudtNamespaces } from "./qudtNamespaces.js"; | ||
import { config, Qudt, QudtlibConfig } from "./qudt.js"; | ||
export { Decimal, Unit, QuantityKind, Prefix, DerivedUnitSearchMode, FactorUnit, FactorUnits, AssignmentProblem, QuantityValue, LangString, Qudt, config, QudtlibConfig, Namespace, SystemOfUnits, QudtNamespaces, }; | ||
//# sourceMappingURL=qudtlib.d.ts.map |
@@ -19,2 +19,3 @@ import { SupportsEquals } from "./baseTypes.js"; | ||
readonly quantityKinds: QuantityKind[]; | ||
readonly exactMatchIris: string[]; | ||
readonly symbol?: string; | ||
@@ -26,5 +27,6 @@ readonly scalingOfIri?: string; | ||
readonly unitOfSystemIris: string[]; | ||
constructor(iri: string, quantityKindIris?: string[], dimensionVectorIri?: string, conversionMultiplier?: Decimal, conversionOffset?: Decimal, prefixIri?: string, scalingOfIri?: string, scalingOf?: Unit, symbol?: string, labels?: LangString[], currencyCode?: string, currencyNumber?: number, unitOfSystemIris?: string[]); | ||
constructor(iri: string, quantityKindIris?: string[], exactMatchIris?: string[], dimensionVectorIri?: string, conversionMultiplier?: Decimal, conversionOffset?: Decimal, prefixIri?: string, scalingOfIri?: string, scalingOf?: Unit, symbol?: string, labels?: LangString[], currencyCode?: string, currencyNumber?: number, unitOfSystemIris?: string[]); | ||
equals(other?: Unit): boolean; | ||
toString(): string; | ||
getIriLocalname(): string; | ||
matchesFactorUnitSpec(...factorUnitSpec: (number | Unit)[]): boolean; | ||
@@ -43,2 +45,3 @@ matches(selection: FactorUnits): boolean; | ||
addQuantityKindIri(quantityKindIri: string): void; | ||
addExactMatchIri(exactMatchIri: string): void; | ||
hasLabel(label: string): boolean; | ||
@@ -45,0 +48,0 @@ getLabelForLanguageTag(languageTag: string): string | undefined; |
{ | ||
"name": "@qudtlib/core", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "Data model for QUDTLib", | ||
@@ -55,3 +55,3 @@ "main": "dist/cjs/qudtlib.js", | ||
}, | ||
"gitHead": "ce7b1bd931491df61eca7adf157df5861a0e2597" | ||
"gitHead": "f46a3bfebd38c8e29b71e3e501964acc3ada8cd4" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
503416
4114