diff --git a/classes/index.Option.html b/classes/index.Option.html index 4c96083..34a5bc4 100644 --- a/classes/index.Option.html +++ b/classes/index.Option.html @@ -1,6 +1,6 @@ -Option | @wopjs/tsur - v0.1.4

Class Option<T>

The Option type is an immutable representation of an optional value: +Option | @wopjs/tsur - v0.1.5

Class Option<T>

The Option type is an immutable representation of an optional value: every Option is either Some and contains a value, or None and does not.

-

Type Parameters

  • T = any

Properties

Type Parameters

  • T = any

Properties

Methods

[iterator] and andThen @@ -31,99 +31,99 @@ Some unwrapOr

Properties

None: None = ...

The None value.

-

Methods

  • Returns an iterator over the possibly contained value.

    +

Methods

  • Returns an iterator over the possibly contained value.

    The iterator yields one value if the result is Some, otherwise none.

    -

    Returns Generator<T, void, unknown>

  • Type Parameters

    • B

    Parameters

    Returns Option<B>

    None if the Option is None, otherwise returns optionB.

    Arguments passed to and are eagerly evaluated; if you are passing the result of a function call, it is recommended to use andThen, which is lazily evaluated.

    -
  • Type Parameters

    • B

    Parameters

  • Type Parameters

    • B

    Parameters

    • getOptionB: ((value: T) => Option<B>)

      A function that returns an Option

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

    Returns Option<B>

    None if the Option is None, otherwise calls getOptionB with the wrapped value and returns the result.

    -
  • Returns None if the Option is None, otherwise calls predicate with the wrapped value and returns:

    +
  • Returns None if the Option is None, otherwise calls predicate with the wrapped value and returns:

    • Some(t) if predicate returns true (where t is the wrapped value with inferred new type), and
    • None if predicate returns false.

    Type Parameters

    • U

    Parameters

    • predicate: ((value: T) => value is U)

      A type predicate function that defines type guard by returning true or false.

        • (value): value is U
        • Parameters

          • value: T

          Returns value is U

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      -

    Returns Option<U>

  • Returns None if the Option is None, otherwise calls predicate with the wrapped value and returns:

    +

Returns Option<U>

  • Returns None if the Option is None, otherwise calls predicate with the wrapped value and returns:

    • Some(t) if predicate returns true (where t is the wrapped value), and
    • None if predicate returns false.

    Parameters

    • predicate: ((value: T) => boolean)

      A function that returns true or false.

        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      -

    Returns Option<T>

    • Returns boolean

      true if the Option is a None.

      -
    • Whether this value is the same as the other Option.

      +

    Returns Option<T>

    • Returns boolean

      true if the Option is a None.

      +
    • Whether this value is the same as the other Option.

      Parameters

      • other: unknown

        Another Option or any value

      Returns boolean

      true if the other is an Option and the value are the same as this value via Object.is.

      -
    • Returns boolean

      true if the Option is a Some.

      -
    • Parameters

      • predicate: ((value: T) => boolean)

        A function that returns true if the value satisfies the predicate, otherwise false

        +
    • Returns boolean

      true if the Option is a Some.

      +
    • Parameters

      • predicate: ((value: T) => boolean)

        A function that returns true if the value satisfies the predicate, otherwise false

          • (value): boolean
          • Parameters

            • value: T

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns boolean

      true if the Option is a Some and and the value inside of it matches a predicate.

      -
    • Maps an Option<T> to Option<U> by applying a function to a contained value (if Some) or returns None (if None).

      +
    • Maps an Option<T> to Option<U> by applying a function to a contained value (if Some) or returns None (if None).

      Type Parameters

      • U

      Parameters

      • fn: ((value: T) => U)

        A function that maps a value to another value

          • (value): U
          • Parameters

            • value: T

            Returns U

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<U>

      None if the Option is None, otherwise returns Some(fn(value)).

      -
    • Extract the value from an Option in a way that handles both the Some and None cases.

      +
    • Extract the value from an Option in a way that handles both the Some and None cases.

      Type Parameters

      • U

      Parameters

      • Some: ((value: T) => U)

        A function that returns a value if the Option is a Some.

          • (value): U
          • Parameters

            • value: T

            Returns U

      • None: (() => U)

        A function that returns a value if the Option is a None.

          • (): U
          • Returns U

      Returns U

      The value returned by the provided function.

      -
    • Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err).

      +
    • Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err).

      Arguments passed to okOr are eagerly evaluated; if you are passing the result of a function call, it is recommended to use okOrElse, which is lazily evaluated.

      Type Parameters

      • E

      Parameters

      • error: E

        The error value for Err if the Option is None.

        -

      Returns Result<T, E>

    • Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err()).

      +

    Returns Result<T, E>

    Returns Option<Exclude<T, Falsy>>

  • Wrap a value in an Option if the value satisfies the predicate.

    Type Parameters

    Parameters

    • source: TSource

      Source value

    • predicate: ((source: TSource) => source is T)

      A function that returns true if the value satisfies the predicate, otherwise false

        • (source): source is T
        • Parameters

          Returns source is T

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      -

    Returns Option<T>

  • Wrap a value in an Option if the value satisfies the predicate.

    +
  • Returns Option<T>

  • Wrap a value in an Option if the value satisfies the predicate.

    Type Parameters

    Parameters

    • source: TSource

      Source value

    • predicate: ((source: TSource) => boolean)

      A function that returns true if the value satisfies the predicate, otherwise false

      -
        • (source): boolean
        • Parameters

          Returns boolean

    • OptionalthisArg: any

    Returns Option<T>

  • +
    diff --git a/classes/index.Result.html b/classes/index.Result.html index ccad1be..52b628c 100644 --- a/classes/index.Result.html +++ b/classes/index.Result.html @@ -1,5 +1,5 @@ -Result | @wopjs/tsur - v0.1.4

    Class Result<T, E>

    The Result type is an immutable representation of either success (Ok) or failure (Err).

    -

    Type Parameters

    • T = any
    • E = any

    Methods

    [iterator] +Result | @wopjs/tsur - v0.1.5

    Class Result<T, E>

    The Result type is an immutable representation of either success (Ok) or failure (Err).

    +

    Type Parameters

    • T = any
    • E = any

    Methods

    [iterator] and andThen err @@ -32,87 +32,87 @@ tryAsync

    Methods

    • Returns an iterator over the possibly contained value.

      The iterator yields one value if the result is Ok, otherwise none.

      -

      Returns Generator<T, void, unknown>

    • Type Parameters

      • BT
      • BE = any

      Parameters

      • getResultB: ((value: T) => Result<BT, BE>)

        A function that returns a Result

        +

        Returns Generator<T, void, unknown>

    • Type Parameters

      • BT
      • BE = any

      Parameters

      • getResultB: ((value: T) => Result<BT, BE>)

        A function that returns a Result

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Result<BT, E | BE>

      Err if the Result is Err, otherwise calls getOptionB with the wrapped value and returns the result.

      -
    • Returns boolean

      true if the Result is an Err.

      -
    • Parameters

      • predicate: ((error: E) => boolean)
          • (error): boolean
          • Parameters

            • error: E

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

        +
    • Returns boolean

      true if the Result is an Err.

      +
    • Parameters

      • predicate: ((error: E) => boolean)
          • (error): boolean
          • Parameters

            • error: E

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns boolean

      true if the Result is an Err and and the error inside of it matches a predicate.

      -
    • Returns boolean

      true if the Result is an Ok.

      -
    • Parameters

      • predicate: ((value: T) => boolean)
          • (value): boolean
          • Parameters

            • value: T

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

        +
    • Returns boolean

      true if the Result is an Ok.

      +
    • Parameters

      • predicate: ((value: T) => boolean)
          • (value): boolean
          • Parameters

            • value: T

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns boolean

      true if the Result is an Ok and and the value inside of it matches a predicate.

      -
    • Whether this Ok value or Err error is the same as the other Result.

      +
    • Whether this Ok value or Err error is the same as the other Result.

      Parameters

      • other: unknown

        Another Result or any value

      Returns boolean

      true if the other is an Result and the Ok value or Err error is the same as this via Object.is.

      -
    • Maps an Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched.

      +
    • Maps an Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched.

      Type Parameters

      • U

      Parameters

      • fn: ((value: T) => U)

        A function that maps a value to another value

          • (value): U
          • Parameters

            • value: T

            Returns U

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Result<U, E>

      Err if the Result is Err, otherwise returns Ok(fn(value)).

      -
    • Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched.

      +
    • Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched.

      This function can be used to pass through a successful result while handling an error.

      Type Parameters

      • U

      Parameters

      • fn: ((error: E) => U)

        A function that maps a error to another error

          • (error): U
          • Parameters

            • error: E

            Returns U

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Result<T, U>

      Ok if the Result is Ok, otherwise returns Err(fn(error)).

      -
    • Extract the value from an Result in a way that handles both the Ok and Err cases.

      +
    • Extract the value from an Result in a way that handles both the Ok and Err cases.

      Type Parameters

      • U

      Parameters

      • Ok: ((value: T) => U)

        A function that returns a value if the Result is a Ok.

          • (value): U
          • Parameters

            • value: T

            Returns U

      • Err: ((error: E) => U)

        A function that returns a value if the Result is a Err.

          • (error): U
          • Parameters

            • error: E

            Returns U

      Returns U

      The value returned by the provided function.

      -
    • Type Parameters

      • BT
      • BE = any

      Parameters

      Returns Result<T | BT, E | BE>

      the Result if it is Ok, otherwise returns resultB.

      Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use orElse, which is lazily evaluated.

      -
    • Type Parameters

      • BT
      • BE = any

      Parameters

      • getResultB: (() => Result<BT, BE>)

        A function that returns an Result

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Result<T | BT, E | BE>

      the Result if it contains a value, otherwise calls getResultB and returns the result.

      -
    • Parameters

      • message: string = "called `Result.unwrap()` on an `Err`"

        Optional Error message

      Returns T

      the contained Ok value.

      if the value is an Err.

      -
    • Parameters

      • message: string = "called `Result.unwrapErr()` on an `Ok` value"

        Optional Error message

        +
    • Parameters

      • message: string = "called `Result.unwrapErr()` on an `Ok` value"

        Optional Error message

      Returns E

      the contained Err error.

      if the error is an Ok.

      -
    • Returns undefined | E

      the contained Err error or undefined otherwise.

      +
    • Returns undefined | E

      the contained Err error or undefined otherwise.

      Arguments passed to unwrapErrOr are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrapErrOrElse, which is lazily evaluated.

      -
    • Type Parameters

      • U

      Parameters

      • defaultError: U

        default error

        +
      • Type Parameters

        • U

        Parameters

        • defaultError: U

          default error

        Returns E | U

        the contained Err error or a provided default.

        Arguments passed to unwrapErrOr are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrapErrOrElse, which is lazily evaluated.

        -
    • Type Parameters

      • U

      Parameters

      • fn: (() => U)

        A function that computes a default value.

        +
    • Type Parameters

      • U

      Parameters

      • fn: (() => U)

        A function that computes a default value.

          • (): U
          • Returns U

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns E | U

      the contained Err error or computes it from a closure.

      -
    • Returns undefined | T

      the contained Ok value or undefined otherwise.

      -
    • Type Parameters

      • U

      Parameters

    • Returns undefined | T

      the contained Ok value or undefined otherwise.

      +
    • Type Parameters

      • U

      Parameters

      • defaultValue: U

        default value

      Returns T | U

      the contained Ok value or a provided default.

      Arguments passed to unwrapOr are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrapOrElse, which is lazily evaluated.

      -
    • Type Parameters

      • U

      Parameters

      • fn: (() => U)

        A function that computes a default value.

        +
    • Type Parameters

      • U

      Parameters

      • fn: (() => U)

        A function that computes a default value.

          • (): U
          • Returns U

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns T | U

      the contained Ok value or computes it from a closure.

      -
    • Type Parameters

      • E
      • T = any

      Parameters

      • error: E

        An error of type E

      Returns Result<T, E>

      Wrap an error into an Result.

      -
    • Err if the value is an Error.

      -

      Type Parameters

      • T = any
      • E extends Error = Error

      Parameters

      • source: T | E

      Returns Result<T, E>

    • OK if the value satisfies the predicate, otherwise Err

      +
    • Err if the value is an Error.

      +

      Type Parameters

      • T = any
      • E extends Error = Error

      Parameters

      • source: T | E

      Returns Result<T, E>

    • OK if the value satisfies the predicate, otherwise Err

      Type Parameters

      • T = any
      • E = any

      Parameters

      • source: T | E

        Source value

      • predicate: ((source: T | E) => source is T)

        A function that returns true if the value satisfies the predicate, otherwise false

          • (source): source is T
          • Parameters

            • source: T | E

            Returns source is T

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

        -

      Returns Result<T, E>

    • OK if the value satisfies the predicate, otherwise Err

      +

    Returns Result<T, E>

  • OK if the value satisfies the predicate, otherwise Err

    Type Parameters

    • T = any
    • E = any

    Parameters

    • source: T | E

      Source value

    • predicate: ((source: T | E) => boolean)

      A function that returns true if the value satisfies the predicate, otherwise false

        • (source): boolean
        • Parameters

          • source: T | E

          Returns boolean

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      -

    Returns Result<T, E>

    • Type Parameters

      • T
      • E

      Parameters

      • maybeResult: unknown

        A value that might be an Result

        +

      Returns Result<T, E>

    • Type Parameters

      • T
      • E

      Parameters

      • maybeResult: unknown

        A value that might be an Result

      Returns maybeResult is Result<T, E>

      true if the given value is an Result.

      -
    • Parameters

    • Parameters

      • a: unknown

        An Result or any value

      • b: unknown

        An Result or any value

      Returns boolean

      true if the both are Result and the Ok value or Err error are the same via Object.is.

      -
    • Type Parameters

      • T
      • E = any

      Parameters

      • value: T

        A value of type T

      Returns Result<T, E>

      Wrap a value into an Result.

      -
    • Ok if the fn returns a value, Err if the fn throws.

      Type Parameters

      • T = any
      • E = any
      • TArgs extends any[] = []

      Parameters

      • fn: ((...args: TArgs) => T)
          • (...args): T
          • Parameters

            Returns T

      • Rest...args: TArgs

      Returns Result<T, E>

      Ok with the returned value or Err with the exception error.

      -
    • Ok if the fn returned Promise resolves a value, Err if the fn throws or the Promise rejected.

      +
    • Ok if the fn returned Promise resolves a value, Err if the fn throws or the Promise rejected.

      Type Parameters

      • T = any
      • E = any
      • TArgs extends any[] = []

      Parameters

      • fn: ((...args: TArgs) => T)
          • (...args): T
          • Parameters

            Returns T

      • Rest...args: TArgs

      Returns Promise<Result<T, E>>

      Ok with the resolved value or Err with the exception error or the rejected value.

      -
    +
    diff --git a/functions/index.Err-1.html b/functions/index.Err-1.html index 0406f7e..c38f526 100644 --- a/functions/index.Err-1.html +++ b/functions/index.Err-1.html @@ -1,5 +1,5 @@ -Err | @wopjs/tsur - v0.1.4

    An error of type E

    +Err | @wopjs/tsur - v0.1.5

    An error of type E

    Wrap an error into an Result.

    +
    diff --git a/functions/index.Ok-1.html b/functions/index.Ok-1.html index cf27959..370adeb 100644 --- a/functions/index.Ok-1.html +++ b/functions/index.Ok-1.html @@ -1,5 +1,5 @@ -Ok | @wopjs/tsur - v0.1.4

    A value of type T

    +Ok | @wopjs/tsur - v0.1.5

    A value of type T

    Wrap a value into an Result.

    +
    diff --git a/functions/index.Some-1.html b/functions/index.Some-1.html index 12198c6..3699599 100644 --- a/functions/index.Some-1.html +++ b/functions/index.Some-1.html @@ -1,5 +1,5 @@ -Some | @wopjs/tsur - v0.1.4

    A value of type T

    +Some | @wopjs/tsur - v0.1.5

    A value of type T

    Wrap a value into an Option.

    +
    diff --git a/functions/index.filterMap.html b/functions/index.filterMap.html index 310f0c4..3c8328f 100644 --- a/functions/index.filterMap.html +++ b/functions/index.filterMap.html @@ -1,7 +1,7 @@ -filterMap | @wopjs/tsur - v0.1.4

    Function filterMap

    filterMap filers and maps an iterable at the same time.

    +filterMap | @wopjs/tsur - v0.1.5

    Function filterMap

    filterMap filers and maps an iterable at the same time.

    It makes chains of filter and map more concise, as it shortens map().filter().map() to a single call.

    • Type Parameters

      • T
      • U

      Parameters

      • arr: T[]

        An array

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns U[]

      An array of filtered and mapped values.

      -
    +
    diff --git a/functions/index.first.html b/functions/index.first.html index 6b3597e..48d79c8 100644 --- a/functions/index.first.html +++ b/functions/index.first.html @@ -1,6 +1,6 @@ -first | @wopjs/tsur - v0.1.4

    Function first

    first finds the first item that matches a predicate. Returns the first item of array if no predicate is provided.

    +first | @wopjs/tsur - v0.1.5

    Function first

    first finds the first item that matches a predicate. Returns the first item of array if no predicate is provided.

    • Type Parameters

      • T

      Parameters

      • arr: T[]

        An array

      • predicate: ((value: T, index: number, array: T[]) => boolean) = truePredicate

        A predicate function.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, the first element is returned.

      Returns Option<T>

      The first item that matches the predicate, or None if no item matches.

      -
    +
    diff --git a/functions/index.firstIndex.html b/functions/index.firstIndex.html index ce404cb..6f451c1 100644 --- a/functions/index.firstIndex.html +++ b/functions/index.firstIndex.html @@ -1,6 +1,6 @@ -firstIndex | @wopjs/tsur - v0.1.4

    Function firstIndex

    Returns the index of the first element in the array that satisfies the provided testing function. Otherwise None is returned.

    +firstIndex | @wopjs/tsur - v0.1.5

    Function firstIndex

    Returns the index of the first element in the array that satisfies the provided testing function. Otherwise None is returned.

    • Type Parameters

      • T

      Parameters

      • arr: T[]

        An array

      • predicate: ((value: T, index: number, array: T[]) => boolean)

        A predicate function.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<number>

      The index of the first item that matches the predicate, or None if no item matches.

      -
    +
    diff --git a/functions/index.firstMap.html b/functions/index.firstMap.html index 91786b3..0e65e7f 100644 --- a/functions/index.firstMap.html +++ b/functions/index.firstMap.html @@ -1,7 +1,7 @@ -firstMap | @wopjs/tsur - v0.1.4

    Function firstMap

    Applies function to the elements of iterator and returns the first non-none result.

    +firstMap | @wopjs/tsur - v0.1.5

    Function firstMap

    Applies function to the elements of iterator and returns the first non-none result.

    firstMap(fn) is the lighter version of filterMap(fn).first().

    • Type Parameters

      • T
      • U

      Parameters

      • arr: T[]

        An array

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<U>

      The first non-none result.

      -
    +
    diff --git a/functions/index.last.html b/functions/index.last.html index 178face..496bd81 100644 --- a/functions/index.last.html +++ b/functions/index.last.html @@ -1,6 +1,6 @@ -last | @wopjs/tsur - v0.1.4

    last finds the last item that matches a predicate. Returns the last item of array if no predicate is provided.

    +last | @wopjs/tsur - v0.1.5

    last finds the last item that matches a predicate. Returns the last item of array if no predicate is provided.

    • Type Parameters

      • T

      Parameters

      • arr: T[]

        An array

      • predicate: ((value: T, index: number, array: T[]) => boolean) = truePredicate

        A predicate function.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, the last element is returned.

      Returns Option<T>

      The last item that matches the predicate, or None if no item matches.

      -
    +
    diff --git a/functions/index.lastIndex.html b/functions/index.lastIndex.html index 0122ad1..2164550 100644 --- a/functions/index.lastIndex.html +++ b/functions/index.lastIndex.html @@ -1,6 +1,6 @@ -lastIndex | @wopjs/tsur - v0.1.4

    Function lastIndex

    Returns the index of the last element in the array where predicate is true, and None otherwise.

    +lastIndex | @wopjs/tsur - v0.1.5

    Function lastIndex

    Returns the index of the last element in the array where predicate is true, and None otherwise.

    • Type Parameters

      • T

      Parameters

      • arr: T[]

        An array

      • predicate: ((value: T, index: number, array: T[]) => boolean)

        lastIndex calls predicate once for each element of the array, in backward order, until it finds one where predicate returns true.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<number>

      The index of the last item that matches the predicate, or None if no item matches.

      -
    +
    diff --git a/functions/index.lastMap.html b/functions/index.lastMap.html index 3a7b3aa..0f72edd 100644 --- a/functions/index.lastMap.html +++ b/functions/index.lastMap.html @@ -1,6 +1,6 @@ -lastMap | @wopjs/tsur - v0.1.4

    Function lastMap

    lastMap(fn) is the lighter version of filterMap(fn).last().

    +lastMap | @wopjs/tsur - v0.1.5

    Function lastMap

    lastMap(fn) is the lighter version of filterMap(fn).last().

    • Type Parameters

      • T
      • U

      Parameters

      • arr: T[]

        An array

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<U>

      The last non-none result.

      -
    +
    diff --git a/functions/index.mapWhile.html b/functions/index.mapWhile.html index 5c8baac..bb95297 100644 --- a/functions/index.mapWhile.html +++ b/functions/index.mapWhile.html @@ -1,6 +1,6 @@ -mapWhile | @wopjs/tsur - v0.1.4

    Function mapWhile

    mapWhile maps an iterable until the first None is encountered.

    +mapWhile | @wopjs/tsur - v0.1.5

    Function mapWhile

    mapWhile maps an iterable until the first None is encountered.

    • Type Parameters

      • T
      • U

      Parameters

      • arr: T[]

        An array

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns U[]

      An array of mapped values.

      -
    +
    diff --git a/functions/index.reduceWhile.html b/functions/index.reduceWhile.html index d394c73..c42dfc7 100644 --- a/functions/index.reduceWhile.html +++ b/functions/index.reduceWhile.html @@ -1,7 +1,7 @@ -reduceWhile | @wopjs/tsur - v0.1.4

    Function reduceWhile

    reduceWhile reduces an iterable until the first None is encountered.

    +reduceWhile | @wopjs/tsur - v0.1.5

    Function reduceWhile

    reduceWhile reduces an iterable until the first None is encountered.

    • Type Parameters

      • T
      • U = T

      Parameters

      • arr: T[]

        An array

      • fn: ((previousValue: U, currentValue: T, currentIndex: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (previousValue, currentValue, currentIndex, array): Option<U>
          • Parameters

            • previousValue: U
            • currentValue: T
            • currentIndex: number
            • array: T[]

            Returns Option<U>

      • initialValue: U

        The initial value.

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns U

      The reduced value.

      -
    +
    diff --git a/index.html b/index.html index 141ffb4..02e0ae7 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ -@wopjs/tsur - v0.1.4

    @wopjs/tsur - v0.1.4

    tsur

    +@wopjs/tsur - v0.1.5

    @wopjs/tsur - v0.1.5

    tsur

    Docs @@ -30,4 +30,4 @@

    See docs for more details.

    MIT @ CRIMX

    -
    +
    diff --git a/interfaces/index.ResultMatcher.html b/interfaces/index.ResultMatcher.html index abfa39e..3402605 100644 --- a/interfaces/index.ResultMatcher.html +++ b/interfaces/index.ResultMatcher.html @@ -1,3 +1,3 @@ -ResultMatcher | @wopjs/tsur - v0.1.4

    Interface ResultMatcher<T, E, U>

    interface ResultMatcher<T, E, U> {
        Err: ((error: E) => U);
        Ok: ((value: T) => U);
    }

    Type Parameters

    • T = any
    • E = any
    • U = any

    Properties

    Err +ResultMatcher | @wopjs/tsur - v0.1.5

    Interface ResultMatcher<T, E, U>

    interface ResultMatcher<T, E, U> {
        Err: ((error: E) => U);
        Ok: ((value: T) => U);
    }

    Type Parameters

    • T = any
    • E = any
    • U = any

    Properties

    Properties

    Err: ((error: E) => U)
    Ok: ((value: T) => U)
    +

    Properties

    Err: ((error: E) => U)
    Ok: ((value: T) => U)
    diff --git a/interfaces/patches_array.Array.html b/interfaces/patches_array.Array.html index 49357ef..df21791 100644 --- a/interfaces/patches_array.Array.html +++ b/interfaces/patches_array.Array.html @@ -1,4 +1,4 @@ -Array | @wopjs/tsur - v0.1.4
    interface Array<T> {
        $filterMap<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): U[];
        $first(predicate?: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<T>;
        $firstIndex(predicate: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<number>;
        $firstMap<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): Option<U>;
        $last(predicate?: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<T>;
        $lastIndex(predicate: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<number>;
        $lastMap<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): Option<U>;
        $mapWhile<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): U[];
        $reduceWhile<U>(fn: ((previousValue: U, currentValue: T, currentIndex: number, array: T[]) => Option<U>), initialValue: U, thisArg?: any): U;
    }

    Type Parameters

    • T

    Methods

    $filterMap +Array | @wopjs/tsur - v0.1.5
    interface Array<T> {
        $filterMap<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): U[];
        $first(predicate?: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<T>;
        $firstIndex(predicate: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<number>;
        $firstMap<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): Option<U>;
        $last(predicate?: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<T>;
        $lastIndex(predicate: ((value: T, index: number, array: T[]) => boolean), thisArg?: any): Option<number>;
        $lastMap<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): Option<U>;
        $mapWhile<U>(fn: ((value: T, index: number, array: T[]) => Option<U>), thisArg?: any): U[];
        $reduceWhile<U>(fn: ((previousValue: U, currentValue: T, currentIndex: number, array: T[]) => Option<U>), initialValue: U, thisArg?: any): U;
    }

    Type Parameters

    • T

    Methods

    $filterMap $first $firstIndex $firstMap @@ -13,46 +13,46 @@

    Type Parameters

    • U

    Parameters

    • fn: ((value: T, index: number, array: T[]) => Option<U>)

      A function that produces an Option.

        • (value, index, array): Option<U>
        • Parameters

          • value: T
          • index: number
          • array: T[]

          Returns Option<U>

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

    Returns U[]

    An array of filtered and mapped values.

    -
    • From tsur.

      first finds the first item that matches a predicate. Returns the first item of array if no predicate is provided.

      Parameters

      • Optionalpredicate: ((value: T, index: number, array: T[]) => boolean)

        A predicate function.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<T>

      The first item that matches the predicate, or None if no item matches.

      -
    • From tsur.

      Returns the index of the first element in the array that satisfies the provided testing function. Otherwise None is returned.

      Parameters

      • predicate: ((value: T, index: number, array: T[]) => boolean)

        A predicate function.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<number>

      The index of the first item that matches the predicate, or None if no item matches.

      -
    • From tsur.

      Applies function to the elements of iterator and returns the first non-none result.

      firstMap(fn) is the lighter version of filterMap(fn).first().

      Type Parameters

      • U

      Parameters

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<U>

      The first non-none result.

      -
    • From tsur.

      last finds the last item that matches a predicate. Returns the last item of array if no predicate is provided.

      Parameters

      • Optionalpredicate: ((value: T, index: number, array: T[]) => boolean)

        A predicate function.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<T>

      The last item that matches the predicate, or None if no item matches.

      -
    • From tsur.

      Returns the index of the last element in the array where predicate is true, and None otherwise.

      Parameters

      • predicate: ((value: T, index: number, array: T[]) => boolean)

        lastIndex calls predicate once for each element of the array, in backward order, until it finds one where predicate returns true.

          • (value, index, array): boolean
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns boolean

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<number>

      The index of the last item that matches the predicate, or None if no item matches.

      -
    • From tsur.

      lastMap(fn) is the lighter version of filterMap(fn).last().

      Type Parameters

      • U

      Parameters

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns Option<U>

      The last non-none result.

      -
    • From tsur.

      mapWhile maps an iterable until the first None is encountered.

      Type Parameters

      • U

      Parameters

      • fn: ((value: T, index: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (value, index, array): Option<U>
          • Parameters

            • value: T
            • index: number
            • array: T[]

            Returns Option<U>

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns U[]

      An array of mapped values.

      -
    • From tsur.

      reduceWhile reduces an iterable until the first None is encountered.

      Type Parameters

      • U = T

      Parameters

      • fn: ((previousValue: U, currentValue: T, currentIndex: number, array: T[]) => Option<U>)

        A function that produces an Option.

          • (previousValue, currentValue, currentIndex, array): Option<U>
          • Parameters

            • previousValue: U
            • currentValue: T
            • currentIndex: number
            • array: T[]

            Returns Option<U>

      • initialValue: U

        The initial value.

      • OptionalthisArg: any

        If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

      Returns U

      The reduced value.

      -
    +
    diff --git a/modules.html b/modules.html index 391d333..b73d7a5 100644 --- a/modules.html +++ b/modules.html @@ -1,3 +1,3 @@ -@wopjs/tsur - v0.1.4

    @wopjs/tsur - v0.1.4

    Index

    Modules

    index +@wopjs/tsur - v0.1.5

    @wopjs/tsur - v0.1.5

    Index

    Modules

    +
    diff --git a/modules/index.html b/modules/index.html index 7d5ebfe..3c0c67c 100644 --- a/modules/index.html +++ b/modules/index.html @@ -1,4 +1,4 @@ -index | @wopjs/tsur - v0.1.4

    Module index

    Index

    Classes

    Option +index | @wopjs/tsur - v0.1.5

    Module index

    Index

    Classes

    Interfaces

    Type Aliases

    Err @@ -21,4 +21,4 @@ Ok reduceWhile Some -
    +
    diff --git a/modules/patches_array.html b/modules/patches_array.html index 1f5773d..537f517 100644 --- a/modules/patches_array.html +++ b/modules/patches_array.html @@ -1,2 +1,2 @@ -patches/array | @wopjs/tsur - v0.1.4

    Module patches/array

    Index

    Interfaces

    +patches/array | @wopjs/tsur - v0.1.5

    Module patches/array

    Index

    Interfaces

    diff --git a/types/index.Err.html b/types/index.Err.html index 4f23d48..b33b906 100644 --- a/types/index.Err.html +++ b/types/index.Err.html @@ -1 +1 @@ -Err | @wopjs/tsur - v0.1.4

    Type Alias Err<E>

    Err<E>: Result<any, E>

    Type Parameters

    • E
    +Err | @wopjs/tsur - v0.1.5

    Type Alias Err<E>

    Err<E>: Result<any, E>

    Type Parameters

    • E
    diff --git a/types/index.None.html b/types/index.None.html index bd4f5f1..c938959 100644 --- a/types/index.None.html +++ b/types/index.None.html @@ -1 +1 @@ -None | @wopjs/tsur - v0.1.4

    Type Alias None

    None: Option<any>
    +None | @wopjs/tsur - v0.1.5

    Type Alias None

    None: Option<any>
    diff --git a/types/index.Ok.html b/types/index.Ok.html index ca63af6..e161fda 100644 --- a/types/index.Ok.html +++ b/types/index.Ok.html @@ -1 +1 @@ -Ok | @wopjs/tsur - v0.1.4

    Type Alias Ok<T>

    Ok<T>: Result<T, any>

    Type Parameters

    • T
    +Ok | @wopjs/tsur - v0.1.5

    Type Alias Ok<T>

    Ok<T>: Result<T, any>

    Type Parameters

    • T
    diff --git a/types/index.Some.html b/types/index.Some.html index 734719e..f411144 100644 --- a/types/index.Some.html +++ b/types/index.Some.html @@ -1 +1 @@ -Some | @wopjs/tsur - v0.1.4

    Type Alias Some<T>

    Some<T>: Option<T>

    Type Parameters

    • T
    +Some | @wopjs/tsur - v0.1.5

    Type Alias Some<T>

    Some<T>: Option<T>

    Type Parameters

    • T
    diff --git a/types/index.UnwrapErr.html b/types/index.UnwrapErr.html index 710b5f5..2291ad9 100644 --- a/types/index.UnwrapErr.html +++ b/types/index.UnwrapErr.html @@ -1 +1 @@ -UnwrapErr | @wopjs/tsur - v0.1.4

    Type Alias UnwrapErr<E, Default>

    UnwrapErr<E, Default>: E extends Result<infer _S, infer U>
        ? U
        : Default

    Type Parameters

    • E
    • Default = E
    +UnwrapErr | @wopjs/tsur - v0.1.5

    Type Alias UnwrapErr<E, Default>

    UnwrapErr<E, Default>: E extends Result<infer _S, infer U>
        ? U
        : Default

    Type Parameters

    • E
    • Default = E
    diff --git a/types/index.UnwrapOk.html b/types/index.UnwrapOk.html index 736728e..4a878bf 100644 --- a/types/index.UnwrapOk.html +++ b/types/index.UnwrapOk.html @@ -1 +1 @@ -UnwrapOk | @wopjs/tsur - v0.1.4

    Type Alias UnwrapOk<T, Default>

    UnwrapOk<T, Default>: T extends Result<infer U>
        ? U
        : Default

    Type Parameters

    • T
    • Default = T
    +UnwrapOk | @wopjs/tsur - v0.1.5

    Type Alias UnwrapOk<T, Default>

    UnwrapOk<T, Default>: T extends Result<infer U>
        ? U
        : Default

    Type Parameters

    • T
    • Default = T
    diff --git a/types/index.UnwrapOption.html b/types/index.UnwrapOption.html index d73bb0d..e7ee000 100644 --- a/types/index.UnwrapOption.html +++ b/types/index.UnwrapOption.html @@ -1 +1 @@ -UnwrapOption | @wopjs/tsur - v0.1.4

    Type Alias UnwrapOption<T, Default>

    UnwrapOption<T, Default>: T extends Option<infer U>
        ? U
        : Default

    Type Parameters

    • T
    • Default = T
    +UnwrapOption | @wopjs/tsur - v0.1.5

    Type Alias UnwrapOption<T, Default>

    UnwrapOption<T, Default>: T extends Option<infer U>
        ? U
        : Default

    Type Parameters

    • T
    • Default = T
    diff --git a/variables/index.None-1.html b/variables/index.None-1.html index e41d62a..c5f13f5 100644 --- a/variables/index.None-1.html +++ b/variables/index.None-1.html @@ -1,2 +1,2 @@ -None | @wopjs/tsur - v0.1.4

    Variable NoneConst

    None: None = ...

    The None value.

    -
    +None | @wopjs/tsur - v0.1.5

    Variable NoneConst

    None: None = ...

    The None value.

    +