Skip to main content Link Search Menu Expand Document (external link)

Take overview

Added in v2.0.0


Table of contents


constructors

chunk

Creates a Take with the specified chunk.

Signature

export declare const chunk: <A>(chunk: Chunk.Chunk<A>) => Take<A, never>

Added in v2.0.0

die

Creates a failing Take with the specified defect.

Signature

export declare const die: (defect: unknown) => Take<never>

Added in v2.0.0

dieMessage

Creates a failing Take with the specified error message.

Signature

export declare const dieMessage: (message: string) => Take<never>

Added in v2.0.0

end

Represents the end-of-stream marker.

Signature

export declare const end: Take<never, never>

Added in v2.0.0

fail

Creates a failing Take with the specified error.

Signature

export declare const fail: <E>(error: E) => Take<never, E>

Added in v2.0.0

failCause

Creates a failing Take with the specified cause.

Signature

export declare const failCause: <E>(cause: Cause.Cause<E>) => Take<never, E>

Added in v2.0.0

fromEffect

Creates an effect from Effect<A, E, R> that does not fail, but succeeds with the Take<A, E>. Error from stream when pulling is converted to Take.failCause. Creates a single value chunk.

Signature

export declare const fromEffect: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Take<A, E>, never, R>

Added in v2.0.0

fromExit

Creates a Take from an Exit.

Signature

export declare const fromExit: <A, E>(exit: Exit.Exit<A, E>) => Take<A, E>

Added in v2.0.0

fromPull

Creates effect from Effect<Chunk<A>, Option<E>, R> that does not fail, but succeeds with the Take<A, E>. Errors from stream when pulling are converted to Take.failCause, and the end-of-stream is converted to Take.end.

Signature

export declare const fromPull: <A, E, R>(
  pull: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, R>
) => Effect.Effect<Take<A, E>, never, R>

Added in v2.0.0

make

Constructs a Take.

Signature

export declare const make: <A, E>(exit: Exit.Exit<Chunk.Chunk<A>, Option.Option<E>>) => Take<A, E>

Added in v2.0.0

of

Creates a Take with a single value chunk.

Signature

export declare const of: <A>(value: A) => Take<A, never>

Added in v2.0.0

destructors

done

Transforms a Take<A, E> to an Effect<A, E>.

Signature

export declare const done: <A, E>(self: Take<A, E>) => Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, never>

Added in v2.0.0

match

Folds over the failure cause, success value and end-of-stream marker to yield a value.

Signature

export declare const match: {
  <Z, E, Z2, A, Z3>(options: {
    readonly onEnd: () => Z
    readonly onFailure: (cause: Cause.Cause<E>) => Z2
    readonly onSuccess: (chunk: Chunk.Chunk<A>) => Z3
  }): (self: Take<A, E>) => Z | Z2 | Z3
  <A, E, Z, Z2, Z3>(
    self: Take<A, E>,
    options: {
      readonly onEnd: () => Z
      readonly onFailure: (cause: Cause.Cause<E>) => Z2
      readonly onSuccess: (chunk: Chunk.Chunk<A>) => Z3
    }
  ): Z | Z2 | Z3
}

Added in v2.0.0

matchEffect

Effectful version of Take.fold.

Folds over the failure cause, success value and end-of-stream marker to yield an effect.

Signature

export declare const matchEffect: {
  <Z, E2, R, E, Z2, R2, A, Z3, E3, R3>(options: {
    readonly onEnd: Effect.Effect<Z, E2, R>
    readonly onFailure: (cause: Cause.Cause<E>) => Effect.Effect<Z2, E2, R2>
    readonly onSuccess: (chunk: Chunk.Chunk<A>) => Effect.Effect<Z3, E3, R3>
  }): (self: Take<A, E>) => Effect.Effect<Z | Z2 | Z3, E2 | E | E3, R | R2 | R3>
  <A, E, Z, E2, R, Z2, R2, Z3, E3, R3>(
    self: Take<A, E>,
    options: {
      readonly onEnd: Effect.Effect<Z, E2, R>
      readonly onFailure: (cause: Cause.Cause<E>) => Effect.Effect<Z2, E2, R2>
      readonly onSuccess: (chunk: Chunk.Chunk<A>) => Effect.Effect<Z3, E3, R3>
    }
  ): Effect.Effect<Z | Z2 | Z3, E | E2 | E3, R | R2 | R3>
}

Added in v2.0.0

getters

isDone

Checks if this take is done (Take.end).

Signature

export declare const isDone: <A, E>(self: Take<A, E>) => boolean

Added in v2.0.0

isFailure

Checks if this take is a failure.

Signature

export declare const isFailure: <A, E>(self: Take<A, E>) => boolean

Added in v2.0.0

isSuccess

Checks if this take is a success.

Signature

export declare const isSuccess: <A, E>(self: Take<A, E>) => boolean

Added in v2.0.0

mapping

map

Transforms Take<A, E> to Take<B, A> by applying function f.

Signature

export declare const map: {
  <A, B>(f: (a: A) => B): <E>(self: Take<A, E>) => Take<B, E>
  <A, E, B>(self: Take<A, E>, f: (a: A) => B): Take<B, E>
}

Added in v2.0.0

models

Take (interface)

A Take<A, E> represents a single take from a queue modeling a stream of values. A Take may be a failure cause Cause<E>, a chunk value Chunk<A>, or an end-of-stream marker.

Signature

export interface Take<out A, out E = never> extends Take.Variance<A, E>, Pipeable {
  /** @internal */
  readonly exit: Exit.Exit<Chunk.Chunk<A>, Option.Option<E>>
}

Added in v2.0.0

sequencing

tap

Returns an effect that effectfully “peeks” at the success of this take.

Signature

export declare const tap: {
  <A, X, E2, R>(
    f: (chunk: Chunk.Chunk<A>) => Effect.Effect<X, E2, R>
  ): <E>(self: Take<A, E>) => Effect.Effect<void, E2 | E, R>
  <A, E, X, E2, R>(
    self: Take<A, E>,
    f: (chunk: Chunk.Chunk<A>) => Effect.Effect<X, E2, R>
  ): Effect.Effect<void, E | E2, R>
}

Added in v2.0.0

symbols

TakeTypeId

Signature

export declare const TakeTypeId: typeof TakeTypeId

Added in v2.0.0

TakeTypeId (type alias)

Signature

export type TakeTypeId = typeof TakeTypeId

Added in v2.0.0

utils

Take (namespace)

Added in v2.0.0

Variance (interface)

Signature

export interface Variance<out A, out E> {
  readonly [TakeTypeId]: {
    readonly _A: Types.Covariant<A>
    readonly _E: Types.Covariant<E>
  }
}

Added in v2.0.0