(n: number)
| 250 | return core.succeed([messages, this.releaseCapacity()]) |
| 251 | }) |
| 252 | takeN(n: number): Effect<readonly [messages: Chunk.Chunk<A>, done: boolean], E> { |
| 253 | return core.suspend(() => { |
| 254 | if (this.state._tag === "Done") { |
| 255 | return core.exitAs(this.state.exit, constDone) |
| 256 | } else if (n <= 0) { |
| 257 | return core.succeed([empty, false]) |
| 258 | } |
| 259 | n = Math.min(n, this.capacity) |
| 260 | let messages: Chunk.Chunk<A> |
| 261 | if (n <= this.messagesChunk.length) { |
| 262 | messages = Chunk.take(this.messagesChunk, n) |
| 263 | this.messagesChunk = Chunk.drop(this.messagesChunk, n) |
| 264 | } else if (n <= this.messages.length + this.messagesChunk.length) { |
| 265 | this.messagesChunk = Chunk.appendAll(this.messagesChunk, Chunk.unsafeFromArray(this.messages)) |
| 266 | this.messages = [] |
| 267 | messages = Chunk.take(this.messagesChunk, n) |
| 268 | this.messagesChunk = Chunk.drop(this.messagesChunk, n) |
| 269 | } else { |
| 270 | return core.zipRight(this.awaitTake, this.takeN(n)) |
| 271 | } |
| 272 | return core.succeed([messages, this.releaseCapacity()]) |
| 273 | }) |
| 274 | } |
| 275 | unsafeTake(): Exit<A, E | NoSuchElementException> | undefined { |
| 276 | if (this.state._tag === "Done") { |
| 277 | return core.exitZipRight(this.state.exit, core.exitFail(new NoSuchElementException())) |
nothing calls this directly
no test coverage detected