Hierarchy

  • NonEmptyListTypeRef
  • Typecasts an array with at least one element into a NonEmptyList. Works only if the compiler can confirm that the array has one or more elements

    Type Parameters

    Parameters

    • list: T

    Returns functional.NonEmptyList<T[number]>

Methods

  • The same function as List#head, but it doesn't return a Maybe as a NonEmptyList will always have a head

    Type Parameters

    • T

    Parameters

    Returns T

  • Returns true and narrows the type if the passed array has one or more elements

    Type Parameters

    • T

    Parameters

    • list: readonly T[]

    Returns list is functional.NonEmptyList<T>

  • The same function as List#last, but it doesn't return a Maybe as a NonEmptyList will always have a last element

    Type Parameters

    • T

    Parameters

    Returns T

  • The same function as List#tail, but it doesn't return a Maybe as a NonEmptyList will always have a tail (although it may be of length 0)

    Type Parameters

    • T

    Parameters

    Returns T[]

  • Typecasts any array into a NonEmptyList, but throws an exception if the array is empty. Use fromArray as a safe alternative

    Type Parameters

    • T

    Parameters

    • source: readonly T[]

    Returns functional.NonEmptyList<T>

Generated using TypeDoc