Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

LazyTransformer fails when multiple values produced per step #49

Open
dphilipson opened this issue Jun 23, 2017 · 0 comments
Open

LazyTransformer fails when multiple values produced per step #49

dphilipson opened this issue Jun 23, 2017 · 0 comments

Comments

@dphilipson
Copy link

dphilipson commented Jun 23, 2017

Running

toIter([[1, 2], [3]], cat)

produces the error

TypeError: Cannot read property 'items' of undefined
    at Object.stepper.@@transducer/step (./node_modules/transducers.js/transducers.js:868:5)
    at Object.newxform.@@transducer/step (./node_modules/transducers.js/transducers.js:743:41)
    at reduce (./node_modules/transducers.js/transducers.js:149:42)
    at Cat.@@transducer/step (./node_modules/transducers.js/transducers.js:747:10)
    at Stepper.@@transducer/step (./node_modules/transducers.js/transducers.js:888:36)
    at LazyTransformer.@@transducer/step (./node_modules/transducers.js/transducers.js:918:38)
    at LazyTransformer.next (./node_modules/transducers.js/transducers.js:903:28)
    at reduce (./node_modules/transducers.js/transducers.js:160:20)
    at toArray (./node_modules/transducers.js/transducers.js:802:12)

where we would expect to get an iterable for the values [1, 2, 3]. For comparison,

toArray([[1, 2], [3]], cat)

produces [1, 2, 3] as expected.

In general, this occurs any time the transducer provided to the constructor of LazyTransformer causes @@transducers/step to be called more than once in its input transformer for a single call in its output transformer. With the transducers provided in this library, this is possible when using the cat and mapcat transducers.

@dphilipson dphilipson changed the title LazyIterator fails when multiple values produced per step LazyTransformer fails when multiple values produced per step Jun 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant