import { Hash } from "@siteimprove/alfa-hash" ; import { Parser } from "@siteimprove/alfa-parser" ; import { Slice } from "@siteimprove/alfa-slice" ; import { Token } from "../syntax/token" ; import { Value } from "../value" ; const { map } = Parser ; /**
 *  https public export class String extends Value < "string" > { public static of ( value ) { return new String ( value ) ; } private readonly _value : string ; private constructor ( value ) { super ( ) ; this . _value = value ; } public get type ( ) : "string" { return "string" ; } public get value ( ) : string { return this . _value ; } public equals ( value ) { return value instanceof String && value . _value === this . _value ; } public hash ( hash ) { hash . writeString ( this . _value ) ; } public toJSON ( ) { return { type : "string" , value : this . _value , } ; } public toString ( ) { return `"${ this . _value . replace ( /"/g , '\\"' ) }"` ; } } public export namespace String { export interface JSON extends Value . JSON < "string" > { value : string ; } export function isString ( value ) { return value instanceof String ; } export const parse = map ( Token . parseString ( ) , ( string ) => String . of ( string . value ) ) ; }