Smart-buffer provides an output buffer which changes the destination depending on content size. https://github.com/fukamachi/smart-buffer