serial.flush()

seems strange to me no such function already exists.

Because most people don't WANT to throw away random amounts of unread data. Why do you?