I'm new to nodejs, so I may be wrong, but It seems to me that there can be some serious design issue with AMFDecoder. My first impression is that it silently assumes blocking io (a habit?).
var amfjs = require("amfjs")
var decoder = new amfjs.AMFDecoder(someKindOfReadableStream)
var value = decoder.decode(amfjs.AMF0) //Decode an AMF0 object
When decoder.decode is called, there may be no data available to reader! It uses pull parsing model, which makes no sense with async io (with streams, obviously, incoming data is "pushed in").
(AMFEncoder, on the other side, should work as expected. It "pushes out" data just when it's available.)
There are (at least) two options: one is to use Buffer instead of Readable. Second is to redesign AMFDecoder - it could emit some event after decoding all data.
The former one seems to be simpler.
If you want some help, let me know!
PS. The tests you wrote also seem to take for granted that data is available when decode is called.
I'm new to nodejs, so I may be wrong, but It seems to me that there can be some serious design issue with AMFDecoder. My first impression is that it silently assumes blocking io (a habit?).
When decoder.decode is called, there may be no data available to reader! It uses pull parsing model, which makes no sense with async io (with streams, obviously, incoming data is "pushed in").
(AMFEncoder, on the other side, should work as expected. It "pushes out" data just when it's available.)
There are (at least) two options: one is to use Buffer instead of Readable. Second is to redesign AMFDecoder - it could emit some event after decoding all data.
The former one seems to be simpler.
If you want some help, let me know!
PS. The tests you wrote also seem to take for granted that data is available when decode is called.