The TeX Catalogue OnLine, Entry for xpeek, Ctan Edition

Define commands that peek ahead in the input stream

The package provides tools to help define commands that, like \xspace and the LaTeX command \textit, peek at what follows them in the command stream and choose appropriate behaviour.