This is now available natively as RegExp.escape(). You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character ...
We use the terms graphemes and characters interchangeably in this README, although technically we are counting Unicode grapheme clusters rather than Unicode characters. tally-ts is a TypeScript ...