import { Parser } from "@siteimprove/alfa-parser" ; import { Slice } from "@siteimprove/alfa-slice" ; import { Token } from "../syntax/token" ; import { Numeric } from "./numeric" ; const { map } = Parser ; /**
 *  https public export class Percentage extends Numeric < "percentage" > { public static of ( value ) { return new Percentage ( value ) ; } private constructor ( value ) { super ( value ) ; } public get type ( ) : "percentage" { return "percentage" ; } public equals ( value ) { return value instanceof Percentage && super . equals ( value ) ; } public toJSON ( ) { return { type : "percentage" , value : this . _value , } ; } public toString ( ) { return `${ this . _value * 100 }%` ; } } public export namespace Percentage { export interface JSON extends Numeric . JSON < "percentage" > { value : number ; } export function isPercentage ( value ) { return value instanceof Percentage ; } export const parse = map ( Token . parsePercentage ( ) , ( percentage ) => Percentage . of ( percentage . value ) ) ; }