`func` can be `undefined` when `buffer` is empty.