MCPcopy
hub / github.com/Effect-TS/effect / scanLeft

Function scanLeft

packages/effect/test/Schedule.test.ts:1009–1017  ·  view source on GitHub ↗
(self: Chunk.Chunk<A>, b: B, f: (b: B, a: A) => B)

Source from the content-addressed store, hash-verified

1007}
1008// TODO(Mike/Max): remove if added to `effect`
1009const scanLeft = <A, B>(self: Chunk.Chunk<A>, b: B, f: (b: B, a: A) => B): Chunk.Chunk<B> => {
1010 const len = self.length
1011 const out = Array.allocate<B>(len + 1) as Array<B>
1012 out[0] = b
1013 for (let i = 0; i < len; i++) {
1014 out[i + 1] = f(out[i], self.pipe(Chunk.unsafeGet(i)))
1015 }
1016 return Chunk.unsafeFromArray(out)
1017}

Callers 1

Schedule.test.tsFile · 0.85

Calls 3

unsafeGetMethod · 0.80
fFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected