import { Comparable , Comparison } from "@siteimprove/alfa-comparable" ; import { Convertible } from "./converter" ; import { Numeric } from "./numeric" ; import { Unit } from "./unit" ; /**
 *  https public export abstract class Dimension < T extends string = string , U extends Unit = Unit , V extends U = U > extends Numeric < T > implements Convertible < U > , Comparable < Dimension < T , U > > { protected readonly _unit : V ; protected constructor ( value , unit ) { super ( value ) ; this . _unit = unit ; } public get unit ( ) : V { return this . _unit ; } /**
     *  https public abstract get canonicalUnit ( ) : U ; public hasUnit < V extends U > ( unit ) { return ( this . _unit as U ) === unit ; } public abstract withUnit < V extends U > ( unit ) ; public equals ( value ) { return ( value instanceof Dimension && super . equals ( value ) && value . _unit === this . _unit ) ; } public compare ( value ) { const a = this . withUnit ( this . canonicalUnit ) ; const b = value . withUnit ( value . canonicalUnit ) ; return Comparable . compareNumber ( a . value , b . value ) ; } } public export namespace Dimension { export interface JSON < T extends string = string > extends Numeric . JSON < T > { unit : Unit ; } export function isDimension ( value ) { return value instanceof Dimension ; } }