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

LazyTransformer fails when multiple values produced per step #49

@dphilipson

Description

@dphilipson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions