import { go } from '@blackglory/go' import { assert } from '@blackglory/errors' import { copyIterable } from './utils.js' export function dropRight( iterable: Iterable , count: number ): IterableIterator { assert(Number.isInteger(count), 'The parameter count must be an integer') assert(count >= 0, 'The parameter count must be greater than or equal to 0') if (count === 0) return copyIterable(iterable) return go(function* () { const arr = Array.from(iterable) yield* arr.slice(0, -count) }) }