utility functions for node.js streams