Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

TArray

44 exports Since v2.0.0 Source

Constructors

Since v2.0.0

Makes an empty TArray.

Signature

declare const empty: <A>() => STM.STM<TArray<A>>

Creates a new TArray from an iterable collection of values.

Signature

declare const fromIterable: <A>(iterable: Iterable<A>) => STM.STM<TArray<A>>
Since v2.0.0

Makes a new TArray that is initialized with specified values.

Signature

declare const make: <Elements extends [any, ...Array<any>]>(...elements: Elements) => STM.STM<TArray<Elements[number]>>

Destructors

Since v2.0.0

Collects all elements into a chunk.

Signature

declare const toArray: <A>(self: TArray<A>) => STM.STM<Array<A>>

Elements

Finds the result of applying a partial function to the first value in its domain.

Signature

declare const collectFirst: {
<A, B>(pf: (a: A) => Option<B>): (self: TArray<A>) => STM<Option<B>>;
<A, B>(self: TArray<A>, pf: (a: A) => Option<B>): STM<Option<B>>;
}

Finds the result of applying an transactional partial function to the first value in its domain.

Signature

declare const collectFirstSTM: {
<A, B, E, R>(pf: (a: A) => Option<STM<B, E, R>>): (self: TArray<A>) => STM<Option<B>, E, R>;
<A, B, E, R>(self: TArray<A>, pf: (a: A) => Option<STM<B, E, R>>): STM<Option<B>, E, R>;
}
Since v2.0.0

Determine if the array contains a specified value.

Signature

declare const contains: {
<A>(value: A): (self: TArray<A>) => STM<boolean>;
<A>(self: TArray<A>, value: A): STM<boolean>;
}
Since v2.0.0

Atomically evaluate the conjunction of a predicate across the members of the array.

Signature

declare const every: {
<A>(predicate: Predicate<A>): (self: TArray<A>) => STM<boolean>;
<A>(self: TArray<A>, predicate: Predicate<A>): STM<boolean>;
}
Since v2.0.0

Atomically evaluate the conjunction of a transactional predicate across the members of the array.

Signature

declare const everySTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>): (self: TArray<A>) => STM<boolean, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>): STM<boolean, E, R>;
}

Find the first element in the array matching the specified predicate.

Signature

declare const findFirst: {
<A>(predicate: Predicate<A>): (self: TArray<A>) => STM<Option<A>>;
<A>(self: TArray<A>, predicate: Predicate<A>): STM<Option<A>>;
}

Get the first index of a specific value in the array.

Signature

declare const findFirstIndex: {
<A>(value: A): (self: TArray<A>) => STM<Option<number>>;
<A>(self: TArray<A>, value: A): STM<Option<number>>;
}

Get the first index of a specific value in the array starting from the specified index.

Signature

declare const findFirstIndexFrom: {
<A>(value: A, from: number): (self: TArray<A>) => STM<Option<number>>;
<A>(self: TArray<A>, value: A, from: number): STM<Option<number>>;
}

Get the index of the first entry in the array matching a predicate.

Signature

declare const findFirstIndexWhere: {
<A>(predicate: Predicate<A>): (self: TArray<A>) => STM<Option<number>>;
<A>(self: TArray<A>, predicate: Predicate<A>): STM<Option<number>>;
}

Get the index of the first entry in the array starting from the specified index, matching a predicate.

Signature

declare const findFirstIndexWhereFrom: {
<A>(predicate: Predicate<A>, from: number): (self: TArray<A>) => STM<Option<number>>;
<A>(self: TArray<A>, predicate: Predicate<A>, from: number): STM<Option<number>>;
}

Starting at specified index, get the index of the next entry that matches a transactional predicate.

Signature

declare const findFirstIndexWhereFromSTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>, from: number): (self: TArray<A>) => STM<Option<number>, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>, from: number): STM<Option<number>, E, R>;
}

Get the index of the next entry that matches a transactional predicate.

Signature

declare const findFirstIndexWhereSTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>): (self: TArray<A>) => STM<Option<number>, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>): STM<Option<number>, E, R>;
}

Find the first element in the array matching a transactional predicate.

Signature

declare const findFirstSTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>): (self: TArray<A>) => STM<Option<A>, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>): STM<Option<A>, E, R>;
}
Since v2.0.0

Find the last element in the array matching a predicate.

Signature

declare const findLast: {
<A>(predicate: Predicate<A>): (self: TArray<A>) => STM<Option<A>>;
<A>(self: TArray<A>, predicate: Predicate<A>): STM<Option<A>>;
}

Get the last index of a specific value in the array bounded above by a specific index.

Signature

declare const findLastIndex: {
<A>(value: A): (self: TArray<A>) => STM<Option<number>>;
<A>(self: TArray<A>, value: A): STM<Option<number>>;
}

Get the last index of a specific value in the array bounded above by a specific index.

Signature

declare const findLastIndexFrom: {
<A>(value: A, end: number): (self: TArray<A>) => STM<Option<number>>;
<A>(self: TArray<A>, value: A, end: number): STM<Option<number>>;
}

Find the last element in the array matching a transactional predicate.

Signature

declare const findLastSTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>): (self: TArray<A>) => STM<Option<A>, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>): STM<Option<A>, E, R>;
}
Since v2.0.0

Atomically performs transactional effect for each item in array.

Signature

declare const forEach: {
<A, R, E>(f: (value: A) => STM<void, E, R>): (self: TArray<A>) => STM<void, E, R>;
<A, R, E>(self: TArray<A>, f: (value: A) => STM<void, E, R>): STM<void, E, R>;
}
Since v2.0.0

Extracts value from ref in array.

Signature

declare const get: {
(index: number): <A>(self: TArray<A>) => STM<A>;
<A>(self: TArray<A>, index: number): STM<A>;
}

The first entry of the array, if it exists.

Signature

declare const headOption: <A>(self: TArray<A>) => STM.STM<Option.Option<A>>

The last entry in the array, if it exists.

Signature

declare const lastOption: <A>(self: TArray<A>) => STM.STM<Option.Option<A>>

Atomically compute the greatest element in the array, if it exists.

Signature

declare const maxOption: {
<A>(order: Order<A>): (self: TArray<A>) => STM<Option<A>>;
<A>(self: TArray<A>, order: Order<A>): STM<Option<A>>;
}

Atomically compute the least element in the array, if it exists.

Signature

declare const minOption: {
<A>(order: Order<A>): (self: TArray<A>) => STM<Option<A>>;
<A>(self: TArray<A>, order: Order<A>): STM<Option<A>>;
}

Atomically reduce the array, if non-empty, by a binary operator.

Signature

declare const reduceOption: {
<A>(f: (x: A, y: A) => A): (self: TArray<A>) => STM<Option<A>>;
<A>(self: TArray<A>, f: (x: A, y: A) => A): STM<Option<A>>;
}

Atomically reduce the non-empty array using a transactional binary operator.

Signature

declare const reduceOptionSTM: {
<A, R, E>(f: (x: A, y: A) => STM<A, E, R>): (self: TArray<A>) => STM<Option<A>, E, R>;
<A, R, E>(self: TArray<A>, f: (x: A, y: A) => STM<A, E, R>): STM<Option<A>, E, R>;
}
Since v2.0.0

Determine if the array contains a value satisfying a predicate.

Signature

declare const some: {
<A>(predicate: Predicate<A>): (self: TArray<A>) => STM<boolean>;
<A>(self: TArray<A>, predicate: Predicate<A>): STM<boolean>;
}
Since v2.0.0

Determine if the array contains a value satisfying a transactional predicate.

Signature

declare const someSTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>): (self: TArray<A>) => STM<boolean, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>): STM<boolean, E, R>;
}

Atomically updates all elements using a pure function.

Signature

declare const transform: {
<A>(f: (value: A) => A): (self: TArray<A>) => STM<void>;
<A>(self: TArray<A>, f: (value: A) => A): STM<void>;
}

Atomically updates all elements using a transactional effect.

Signature

declare const transformSTM: {
<A, R, E>(f: (value: A) => STM<A, E, R>): (self: TArray<A>) => STM<void, E, R>;
<A, R, E>(self: TArray<A>, f: (value: A) => STM<A, E, R>): STM<void, E, R>;
}
Since v2.0.0

Updates element in the array with given function.

Signature

declare const update: {
<A>(index: number, f: (value: A) => A): (self: TArray<A>) => STM<void>;
<A>(self: TArray<A>, index: number, f: (value: A) => A): STM<void>;
}

Atomically updates element in the array with given transactional effect.

Signature

declare const updateSTM: {
<A, R, E>(index: number, f: (value: A) => STM<A, E, R>): (self: TArray<A>) => STM<void, E, R>;
<A, R, E>(self: TArray<A>, index: number, f: (value: A) => STM<A, E, R>): STM<void, E, R>;
}

Folding

Since v2.0.0

Count the values in the array matching a predicate.

Signature

declare const count: {
<A>(predicate: Predicate<A>): (self: TArray<A>) => STM<number>;
<A>(self: TArray<A>, predicate: Predicate<A>): STM<number>;
}
Since v2.0.0

Count the values in the array matching a transactional predicate.

Signature

declare const countSTM: {
<A, R, E>(predicate: (value: A) => STM<boolean, E, R>): (self: TArray<A>) => STM<number, E, R>;
<A, R, E>(self: TArray<A>, predicate: (value: A) => STM<boolean, E, R>): STM<number, E, R>;
}
Since v2.0.0

Atomically folds using a pure function.

Signature

declare const reduce: {
<Z, A>(zero: Z, f: (accumulator: Z, current: A) => Z): (self: TArray<A>) => STM<Z>;
<Z, A>(self: TArray<A>, zero: Z, f: (accumulator: Z, current: A) => Z): STM<Z>;
}

Atomically folds using a transactional function.

Signature

declare const reduceSTM: {
<Z, A, R, E>(zero: Z, f: (accumulator: Z, current: A) => STM<Z, E, R>): (self: TArray<A>) => STM<Z, E, R>;
<Z, A, R, E>(self: TArray<A>, zero: Z, f: (accumulator: Z, current: A) => STM<Z, E, R>): STM<Z, E, R>;
}

Getters

Since v2.0.0

Returns the size of the TArray.

Signature

declare const size: <A>(self: TArray<A>) => number

Models

TArray

interface
Since v2.0.0

Signature

interface TArray<in out A> extends Variance<A> {}

Other

Since v2.0.0

Symbols

Signature

declare const TArrayTypeId: unique symbol
Since v2.0.0

Signature

type TArrayTypeId = typeof TArrayTypeId