import { Applicative } from "@siteimprove/alfa-applicative" ; import { Callback } from "@siteimprove/alfa-callback" ; import { Comparable , Comparer , Comparison } from "@siteimprove/alfa-comparable" ; import { Equatable } from "@siteimprove/alfa-equatable" ; import { Foldable } from "@siteimprove/alfa-foldable" ; import { Functor } from "@siteimprove/alfa-functor" ; import { Hashable } from "@siteimprove/alfa-hash" ; import { Iterable } from "@siteimprove/alfa-iterable" ; import { Serializable } from "@siteimprove/alfa-json" ; import { Mapper } from "@siteimprove/alfa-mapper" ; import { Monad } from "@siteimprove/alfa-monad" ; import { Option } from "@siteimprove/alfa-option" ; import { Predicate } from "@siteimprove/alfa-predicate" ; import { Reducer } from "@siteimprove/alfa-reducer" ; import { Refinement } from "@siteimprove/alfa-refinement" ; public export interface Collection < T > extends Functor < T > , Applicative < T > , Monad < T > , Foldable < T > , Equatable , Hashable { readonly size : number ; isEmpty ( ) : this is Collection < never > ; forEach ( callback ) : void ; map < U > ( mapper ) : Collection < U > ; apply < U > ( mapper ) : Collection < U > ; flatMap < U > ( mapper ) : Collection < U > ; flatten < T > ( this ) : Collection < T > ; reduce < U > ( reducer , accumulator ) : U ; filter < U extends T > ( refinement ) : Collection < U > ; filter ( predicate ) : Collection < T > ; reject < U extends T > ( refinement ) : Collection < Exclude < T , U > > ; reject ( predicate ) : Collection < T > ; find < U extends T > ( refinement ) : Option < U > ; find ( predicate ) : Option < T > ; includes ( value ) : boolean ; collect < U > ( mapper ) : Collection < U > ; collectFirst < U > ( mapper ) : Option < U > ; some ( predicate ) : boolean ; none ( predicate ) : boolean ; every ( predicate ) : boolean ; count ( predicate ) : number ; distinct ( ) : Collection < T > ; } public export namespace Collection { export interface Keyed < K , V > extends Collection < V > , Iterable < [ K , V ] > , Serializable < Keyed . JSON < K , V > > { isEmpty ( ) : this is Keyed < K , never > ; forEach ( callback ) : void ; map < U > ( mapper ) : Keyed < K , U > ; apply < U > ( mapper ) : Keyed < K , U > ; flatMap < U > ( mapper ) : Keyed < K , U > ; flatten < K , V > ( this ) : Keyed < K , V > ; reduce < U > ( reducer , accumulator ) : U ; filter < U extends V > ( refinement ) : Keyed < K , U > ; filter ( predicate ) : Keyed < K , V > ; reject < U extends V > ( refinement ) : Keyed < K , Exclude < V , U > > ; reject ( predicate ) : Keyed < K , V > ; find < U extends V > ( refinement ) : Option < U > ; find ( predicate ) : Option < V > ; includes ( value ) : boolean ; collect < U > ( mapper ) : Keyed < K , U > ; collectFirst < U > ( mapper ) : Option < U > ; some ( predicate ) : boolean ; none ( predicate ) : boolean ; every ( predicate ) : boolean ; count ( predicate ) : number ; distinct ( ) : Keyed < K , V > ; get ( key ) : Option < V > ; has ( key ) : boolean ; set ( key , value ) : Keyed < K , V > ; delete ( key , value ) : Keyed < K , V > ; concat ( iterable ) : Keyed < K , V > ; subtract ( iterable ) : Keyed < K , V > ; intersect ( iterable ) : Keyed < K , V > ; } export namespace Keyed { export type JSON < K , V > = Array < [ Serializable . ToJSON < K > , Serializable . ToJSON < V > ] > ; } export interface Unkeyed < T > extends Collection < T > , Iterable < T > , Serializable < Unkeyed . JSON < T > > { isEmpty ( ) : this is Unkeyed < never > ; forEach ( callback ) : void ; map < U > ( mapper ) : Unkeyed < U > ; apply < U > ( mapper ) : Unkeyed < U > ; flatMap < U > ( mapper ) : Unkeyed < U > ; flatten < T > ( this ) : Unkeyed < T > ; reduce < U > ( reducer , accumulator ) : U ; filter < U extends T > ( refinement ) : Unkeyed < U > ; filter ( predicate ) : Unkeyed < T > ; reject < U extends T > ( refinement ) : Unkeyed < Exclude < T , U > > ; reject ( predicate ) : Unkeyed < T > ; find < U extends T > ( refinement ) : Option < U > ; find ( predicate ) : Option < T > ; includes ( value ) : boolean ; collect < U > ( mapper ) : Unkeyed < U > ; collectFirst < U > ( mapper ) : Option < U > ; some ( predicate ) : boolean ; none ( predicate ) : boolean ; every ( predicate ) : boolean ; count ( predicate ) : number ; distinct ( ) : Unkeyed < T > ; get ( value ) : Option < T > ; has ( value ) : boolean ; add ( value ) : Unkeyed < T > ; delete ( value ) : Unkeyed < T > ; concat ( iterable ) : Unkeyed < T > ; subtract ( iterable ) : Unkeyed < T > ; intersect ( iterable ) : Unkeyed < T > ; } export namespace Unkeyed { export type JSON < T > = Array < Serializable . ToJSON < T > > ; } export interface Indexed < T > extends Collection < T > , Iterable < T > , Comparable < Iterable < T > > , Serializable < Indexed . JSON < T > > { isEmpty ( ) : this is Indexed < never > ; forEach ( callback ) : void ; map < U > ( mapper ) : Indexed < U > ; apply < U > ( mapper ) : Indexed < U > ; flatMap < U > ( mapper ) : Indexed < U > ; flatten < T > ( this ) : Indexed < T > ; reduce < U > ( reducer , accumulator ) : U ; reduceWhile < U > ( predicate , reducer , accumulator ) : U ; reduceUntil < U > ( predicate , reducer , accumulator ) : U ; filter < U extends T > ( refinement ) : Indexed < U > ; filter ( predicate ) : Indexed < T > ; reject < U extends T > ( refinement ) : Indexed < Exclude < T , U > > ; reject ( predicate ) : Indexed < T > ; find < U extends T > ( refinement ) : Option < U > ; find ( predicate ) : Option < T > ; includes ( value ) : boolean ; collect < U > ( mapper ) : Indexed < U > ; collectFirst < U > ( mapper ) : Option < U > ; some ( predicate ) : boolean ; none ( predicate ) : boolean ; every ( predicate ) : boolean ; count ( predicate ) : number ; distinct ( ) : Indexed < T > ; get ( index ) : Option < T > ; has ( index ) : boolean ; set ( index , value ) : Indexed < T > ; insert ( index , value ) : Indexed < T > ; append ( value ) : Indexed < T > ; prepend ( value ) : Indexed < T > ; concat ( iterable ) : Indexed < T > ; subtract ( iterable ) : Indexed < T > ; intersect ( iterable ) : Indexed < T > ; zip < U > ( iterable ) : Indexed < [ T , U ] > ; first ( ) : Option < T > ; last ( ) : Option < T > ; take ( count ) : Indexed < T > ; takeWhile < U extends T > ( refinement ) : Indexed < U > ; takeWhile ( predicate ) : Indexed < T > ; takeUntil ( predicate ) : Indexed < T > ; takeLast ( count ) : Indexed < T > ; takeLastWhile < U extends T > ( refinement ) : Indexed < U > ; takeLastWhile ( predicate ) : Indexed < T > ; takeLastUntil ( predicate ) : Indexed < T > ; skip ( count ) : Indexed < T > ; skipWhile ( predicate ) : Indexed < T > ; skipUntil ( predicate ) : Indexed < T > ; skipLast ( count ) : Indexed < T > ; skipLastWhile ( predicate ) : Indexed < T > ; skipLastUntil ( predicate ) : Indexed < T > ; trim ( predicate ) : Indexed < T > ; trimLeading ( predicate ) : Indexed < T > ; trimTrailing ( predicate ) : Indexed < T > ; rest ( ) : Indexed < T > ; slice ( start , end ? ) : Indexed < T > ; reverse ( ) : Indexed < T > ; join ( separator ) : string ; sort < T extends Comparable < T > > ( this ) : Indexed < T > ; sortWith ( comparer ) : Indexed < T > ; compare < T > ( this , iterable ) : Comparison ; compareWith < U = T > ( iterable , comparer ) : Comparison ; } export namespace Indexed { export type JSON < T > = Array < Serializable . ToJSON < T > > ; } }