import { Comparable , Comparison } from "@siteimprove/alfa-comparable" ; import { Hash } from "@siteimprove/alfa-hash" ; import { Thunk } from "@siteimprove/alfa-thunk" ; import * as json from "@siteimprove/alfa-json" ; import { Option } from "./option" ; import { Some } from "./some" ; const { compareComparable } = Comparable ; public export interface None extends Option < never > { } public export const None = new ( class None { public isSome ( ) { return false ; } public isNone ( ) { return true ; } public map ( ) { return this ; } public apply ( ) { return this ; } public flatMap ( ) { return this ; } public flatten ( ) { return this ; } public reduce < U > ( reducer , accumulator ) { return accumulator ; } public filter ( ) { return this ; } public reject ( ) { return this ; } public includes ( ) { return false ; } public some ( ) { return false ; } public none ( ) { return true ; } public every ( ) { return true ; } public and ( ) { return this ; } public andThen ( ) { return this ; } public or < U > ( option ) { return option ; } public orElse < U > ( option ) { return option ( ) ; } public get ( message = "Attempted to .get() from None" ) { throw new Error ( message ) ; } public getOr < U > ( value ) { return value ; } public getOrElse < U > ( value ) { return value ( ) ; } public tee ( ) { return this ; } public compare < T > ( this , option ) { return this . compareWith ( option , compareComparable ) ; } public compareWith < T > ( option ) { return option . isNone ( ) ? Comparison . Equal : Comparison . Less ; } public equals ( value ) { return value instanceof None ; } public hash ( hash ) { hash . writeBoolean ( false ) ; } public * [ Symbol . iterator ] ( ) { } public toArray ( ) { return [ ] ; } public toJSON ( ) { return { type : "none" , } ; } public toString ( ) { return "None" ; } } ) ( ) ; public export namespace None { export interface JSON { [ key ] : json . JSON ; type : "none" ; } }