Insert \thinspace only if not followed by certain characters

(Cross-posted from <>.)

Following a tip I'd seen, I’ve defined a \spaceddash command and
assigned it to the Unicode em-dash character U+2014 “—”:


meow — meow


— meow

meow —.

The last line before \end{document} shows a problem with this: there's a
\thinspace between the em-dash and the period afterward, and I'd rather
not have it there.

Following the example of xspace & xpunctuate, I'm trying to define a
sort of \xthinspace command, one that will insert the \thinspace except
if the dash is followed by certain punctuation marks (e.g., period,
comma, close-parenthesis, close-quote).

How do I go about this?