This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Implementation bug in normaliseInput #3138
Copy link
Copy link
Labels
exp/noviceSomeone with a little familiarity can pick upSomeone with a little familiarity can pick upstatus/readyReady to be workedReady to be worked
Description
I am pretty sure following lines would throw TypeError: iterator is not iterable
because yield *
expression expects iterable and not an iterator.
js-ipfs/packages/ipfs-core-utils/src/files/normalise-input.js
Lines 73 to 82 in 8cb8c73
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 |
js-ipfs/packages/ipfs-core-utils/src/files/normalise-input.js
Lines 114 to 122 in 8cb8c73
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 |
js-ipfs/packages/ipfs-core-utils/src/files/normalise-input.js
Lines 191 to 199 in 8cb8c73
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 upSomeone with a little familiarity can pick upstatus/readyReady to be workedReady to be worked