@tempots/std
jsQuote() function
Quotes a string for use in JavaScript code. If the string contains a newline character, it will be quoted using backticks. Otherwise, it will be quoted using single quotes ('
) or double quotes ("
) based on the prefer
parameter.
Signature:
jsQuote: (s: string, prefer?: string) => string
Parameters
Parameter |
Type |
Description |
---|---|---|
s |
string |
The string to be quoted. |
prefer |
string |
(Optional) The preferred quote character. Defaults to single quote ( |
Returns: string
The quoted string.