Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Implementation bug in normaliseInput #3138

@Gozala

Description

@Gozala

I am pretty sure following lines would throw TypeError: iterator is not iterable because yield * expression expects iterable and not an iterator.

const iterator = input[Symbol.iterator]()
const first = iterator.next()
if (first.done) return iterator
// Iterable<Number>
// Iterable<Bytes>
if (Number.isInteger(first.value) || isBytes(first.value)) {
yield toFileObject((function * () {
yield first.value
yield * iterator

const iterator = input[Symbol.asyncIterator]()
const first = await iterator.next()
if (first.done) return iterator
// AsyncIterable<Bytes>
if (isBytes(first.value)) {
yield toFileObject((async function * () { // eslint-disable-line require-await
yield first.value
yield * iterator

const iterator = input[Symbol.iterator]()
const first = iterator.next()
if (first.done) return iterator
// Iterable<Number>
if (Number.isInteger(first.value)) {
yield toBuffer(Array.from((function * () {
yield first.value
yield * iterator

It is also worrying that no tests seem to catch that.

Metadata

Metadata

Assignees

Labels

exp/noviceSomeone with a little familiarity can pick upstatus/readyReady to be worked

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions