Support generic streams, not just Buffer

@purplefox can you review this ?
I think the previous value is a reasonable default, but I think -1 is definitely not a good choice.