Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Some<A>

Class Some<A> represents existing values of type A. Some never contains null or undefined.

const a:any = "anything"
const b: Some<any> = new Some<any>(a)
const c: Some<any> = Option.some(a)
const d: Some<any> = Option(a)
const e: Some<any> = Option.some(a)
const f: Some<any> = Option.apply(a)

Type parameters

  • A

Hierarchy

  • Some

Implements

Index

Constructors

constructor

  • new Some(value: A): Some

Properties

exists

exists: has = this.has

isDefined

isDefined: boolean = this.isSome

isEmpty

isEmpty: boolean = this.isNone

isNone

isNone: boolean = false

isSome

isSome: boolean = true

Readonly type

type: string = "Some"

Readonly value

value: A

Methods

ap

filter

  • filter(p: (a: A) => boolean): Option<A>
  • Parameters

    • p: (a: A) => boolean
        • (a: A): boolean
        • Parameters

          • a: A

          Returns boolean

    Returns Option<A>

flatMap

flatten

forEach

  • forEach(fn: (a: A) => any): void
  • Parameters

    • fn: (a: A) => any
        • (a: A): any
        • Parameters

          • a: A

          Returns any

    Returns void

get

  • get(): A

getOrElse

  • getOrElse(x: A): A

has

  • has(p: (a: A) => boolean): boolean
  • Parameters

    • p: (a: A) => boolean
        • (a: A): boolean
        • Parameters

          • a: A

          Returns boolean

    Returns boolean

map

  • map<B>(f: (a: A) => B): Option<B>
  • Type parameters

    • B

    Parameters

    • f: (a: A) => B
        • (a: A): B
        • Parameters

          • a: A

          Returns B

    Returns Option<B>

orElse

toList

  • toList(): A[]

Generated using TypeDoc