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

Function take

packages/effect/src/MutableList.ts:534–548  ·  view source on GitHub ↗
(self: MutableList<A>)

Source from the content-addressed store, hash-verified

532 * @since 4.0.0
533 */
534export const take = <A>(self: MutableList<A>): Empty | A => {
535 if (!self.head) return Empty
536 const message = self.head.array[self.head.offset]
537 if (self.head.mutable) self.head.array[self.head.offset] = undefined as any
538 self.head.offset++
539 self.length--
540 if (self.head.offset === self.head.array.length) {
541 if (self.head.next) {
542 self.head = self.head.next
543 } else {
544 clear(self)
545 }
546 }
547 return message
548}
549
550/**
551 * Copies up to `n` elements from the beginning of the `MutableList` into a new

Callers

nothing calls this directly

Calls 1

clearFunction · 0.70

Tested by

no test coverage detected