Description
In the browser we've got the Blob
object, which represents some binary data that typically is stored in the hard drive. If we want to read said data, we use the FileReader
object. Sometimes, we just don't need to read that data, instead we want to send it, and the actual contents of it don't mind us at all.
In the browser this is straightforward, we just obj.send(blob);
, but if we want to do the same thing using node's Buffer
API, we've got to read that data from the hard drive first, and thus consuming a considerable amount of memory, and then send it. The closest thing to sending Blobs I can think of in the Node world is stream.pipe(otherStream);
but this is still implemented on plain javascript, loading hd data in memory bit by bit. Multiply those bits of binary data by thousands of connections and you may find a bottleneck.
Such operations should be done on a lower level, allowing things like the sendfile
system call. Imo, implementing the Blob
object, at first as some sugar around fs
and later as a full lower level implementation, would allow us to save some memory and, at the same time, reduce the gap between Node and the browser's worlds.