import { Option , Some , None } from "@siteimprove/alfa-option" ; import { Refinement } from "@siteimprove/alfa-refinement" ; import { EARL } from "./earl" ; const { isFunction , isObject } = Refinement ; public export interface Serializable < T extends EARL = EARL > { toEARL ( ) : T ; } public export namespace Serializable { export function isSerializable < T extends EARL > ( value ) { return isObject ( value ) && isFunction ( value . toEARL ) ; } export function toEARL < T extends EARL > ( value ) ; export function toEARL ( value ) ; export function toEARL ( value ) { if ( isSerializable ( value ) ) { return Some . of ( value . toEARL ( ) ) ; } return None ; } }