0.1.3 #4
@@ -157,3 +157,30 @@ export const makeFromChunkFindFirst: {
|
||||
index => Chunk.replace(parentValue, index, value),
|
||||
)),
|
||||
) as any
|
||||
|
||||
export const makeFromChunkFindLast: {
|
||||
<B extends SubscriptionRef.SubscriptionRef<Chunk.NonEmptyChunk<any>>>(
|
||||
parent: B,
|
||||
findLastPredicate: Predicate.Predicate<Effect.Effect.Success<B> extends Chunk.NonEmptyChunk<infer A> ? A : never>,
|
||||
): SubscriptionSubRef<
|
||||
Effect.Effect.Success<B> extends Chunk.NonEmptyChunk<infer A> ? A : never,
|
||||
B
|
||||
>
|
||||
<B extends SubscriptionRef.SubscriptionRef<Chunk.Chunk<any>>>(
|
||||
parent: B,
|
||||
findLastPredicate: Predicate.Predicate<Effect.Effect.Success<B> extends Chunk.Chunk<infer A> ? A : never>,
|
||||
): SubscriptionSubRef<
|
||||
Effect.Effect.Success<B> extends Chunk.Chunk<infer A> ? A : never,
|
||||
B
|
||||
>
|
||||
} = (
|
||||
parent: SubscriptionRef.SubscriptionRef<Chunk.Chunk<never>>,
|
||||
findLastPredicate: Predicate.Predicate.Any,
|
||||
) => new SubscriptionSubRefImpl(
|
||||
parent,
|
||||
parentValue => Option.getOrThrow(Chunk.findLast(parentValue, findLastPredicate)),
|
||||
(parentValue, value) => Option.getOrThrow(Option.andThen(
|
||||
Chunk.findLastIndex(parentValue, findLastPredicate),
|
||||
index => Chunk.replace(parentValue, index, value),
|
||||
)),
|
||||
) as any
|
||||
|
||||
Reference in New Issue
Block a user