function stringifySafely(rawValue, parser, encoder) {
  if (utils$1.isString(rawValue)) {
    try {
      (parser || JSON.parse)(rawValue);
      return utils$1.trim(rawValue);
    } catch (e) {
      if (e.name !== 'SyntaxError') {
        throw e;
      }
    }
  }

  return (encoder || JSON.stringify)(rawValue);
}
It takes a string, tries to parse it, and if it fails, it returns the stringified version
of the input

@param {any} rawValue - The value to be stringified.
@param {Function} parser - A function that parses a string into a JavaScript object.
@param {Function} encoder - A function that takes a value and returns a string.

@returns {string} A stringified version of the rawValue.