import { None } from './none' ; import { Option } from './option' ; /**
 * Some represents non-emptiness.  It signals that a value that may not exist does actually exist.
 */ class Some < A > implements Option < A > { private value : A ; get isDefined ( ) : boolean { return true ; } get isEmpty ( ) : boolean { return false ; } constructor ( value ) { this . value = value ; } equals < B > ( other ) { return ( other instanceof Some ) && this . get ( ) === other . get ( ) ; } filter ( predicate ) { if ( predicate ( this . value ) ) { return this ; } else { return None ; } } filterNot ( predicate ) { if ( ! predicate ( this . value ) ) { return this ; } else { return None ; } } flatMap < B > ( flatMapper ) { return flatMapper ( this . value ) ; } foreach ( run ) { run ( this . value ) ; } get ( ) { return this . value ; } getOrElse < B , A extends B > ( this , defaultValue ) { return this . value ; } map < B > ( mapper ) { return new Some ( mapper ( this . value ) ) ; } match < B > ( matcher ) { return matcher . Some ( this . value ) ; } orElse < B , A extends B > ( this , alternative ) { return this ; } } export { Some } ;