Literal escaping neutralizes syntax without adding delimiters
Safe escaping is broader than adding a backslash before punctuation. ECMAScript escapes a leading ASCII letter or digit, several punctuators, whitespace, line breaks, syntax characters, and lone surrogates in different ways so the fragment can be concatenated safely.
The output follows the RegExp.escape algorithm shape, including hexadecimal escaping for a leading alphanumeric and punctuators such as hyphen. It does not add / delimiters or flags, leaving integration choices to the caller.