| 532 | * @since 4.0.0 |
| 533 | */ |
| 534 | export 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 |