MCPcopy Create free account
hub / github.com/Effect-TS/effect / indexWhere

Function indexWhere

packages/effect/src/internal/sink.ts:1839–1852  ·  view source on GitHub ↗
(self: Chunk.Chunk<A>, predicate: Predicate<A>, from = 0)

Source from the content-addressed store, hash-verified

1837
1838/** @internal */
1839const indexWhere = <A>(self: Chunk.Chunk<A>, predicate: Predicate<A>, from = 0): number => {
1840 const iterator = self[Symbol.iterator]()
1841 let index = 0
1842 let result = -1
1843 let next: IteratorResult<A, any>
1844 while (result < 0 && (next = iterator.next()) && !next.done) {
1845 const a = next.value
1846 if (index >= from && predicate(a)) {
1847 result = index
1848 }
1849 index = index + 1
1850 }
1851 return result
1852}
1853
1854/** @internal */
1855export const succeed = <A>(a: A): Sink.Sink<A, unknown> => new SinkImpl(core.succeed(a))

Callers 1

splitWhereSplitterFunction · 0.85

Calls 2

nextMethod · 0.65
predicateFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…