/** * Finds the key/value pair matching the specified predicate, and uses the * provided effectful function to extract a value out of it. * * @tsplus static effect/core/stm/TMap.Aspects findSTM * @tsplus pipeable effect/core/stm/TMap findSTM */ export function findSTM( f: (kv: readonly [K, V]) => STM, A> ) { return (self: TMap): STM> => self.foldSTM(Maybe.empty(), (a, kv) => { if (a.isNone()) { return f(kv).foldSTM((_) => _.fold(STM.none, (e) => STM.fail(e)), STM.some) } return STM.succeed(a) }) }