I'm not a V8 expert, but could it be optimized by making an array like the EventEmitter does and maybe keep an counter if the same function reference is passed to multiple writes?

If we want to call the callback before the whole string is written, we need to stop concatenate the string. But I do not understand the whole reason why it is done in the first place.