kevva / decompress

Extracting archives made easy
MIT License
415 stars 51 forks source link

decompress and plugins are inconsistent about whether you can pass in a stream #58

Open glasser opened 7 years ago

glasser commented 7 years ago

Most decompress plugins allow input to be a stream. But decompress itself requires it to be a Buffer or a filename, and the filename is converted to a Buffer not a stream. I get that eg decompress-tar takes a stream because it might get one from decompress-targz, but it's unclear why decompress-targz (eg) is allowed to take a stream.

Moreover, it would be beneficial from a performance standpoint if you could pass in a stream to plugins like the tar ones that support it. Yes, it would mean that automatic type detection wouldn't work, but if you're explicitly specifying a single plugin like decompressTargz then that doesn't matter.

57 at least will document explicitly that this package always reads the whole file into memory. But it would be nice if this package (with such a nice API) didn't waste so much memory.