Skip to content

String objects are not supported #11

@yonivy

Description

@yonivy

Based on the README I tried the following snippet

let buf = new String('{"hello":"world"}')
buf.name = "filename1"

m = structurize.multi()
m.write(buf)

which failed with

events.js:160
      throw er; // Unhandled 'error' event
      ^

TypeError: Invalid non-string/buffer chunk
    at validChunk (_stream_writable.js:211:10)
    at Stream.Writable.write (_stream_writable.js:241:21)
    at Multi._transform (/Users/yonilevy/Code/junkyard/structurize-test/node_modules/structurize/index.js:260:27)
    at Multi.Transform._read (_stream_transform.js:167:10)
    at Multi.Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:331:12)
    at writeOrBuffer (_stream_writable.js:317:5)
    at Multi.Writable.write (_stream_writable.js:243:11)
    at Object.<anonymous> (/Users/yonilevy/Code/junkyard/structurize-test/index.js:8:3)
    at Module._compile (module.js:570:32)

It seems that we can't simply write String objects, and might need to convert them to something else. I personally doubt we should use String objects at all knowing we have Buffers to rely on, but nonetheless at this point this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions