function format (value, options) {
  const result = _format(value, options)
  if (options && typeof options === 'object' && 'truncate' in options &&
      result.length > options.truncate) {
    return result.substring(0, options.truncate - 3) + '...'
  }
  return result
}
Format a value of any type into a string.

Usage:
    math.format(value)
    math.format(value, precision)
    math.format(value, options)

When value is a function:

- When the function has a property `syntax`, it returns this
  syntax description.
- In other cases, a string `'function'` is returned.

When `value` is an Object:

- When the object contains a property `format` being a function, this
  function is invoked as `value.format(options)` and the result is returned.
- When the object has its own `toString` method, this method is invoked
  and the result is returned.
- In other cases the function will loop over all object properties and
  return JSON object notation like '{"a": 2, "b": 3}'.

Example usage:
    math.format(2/7)                // '0.2857142857142857'
    math.format(math.pi, 3)         // '3.14'
    math.format(new Complex(2, 3))  // '2 + 3i'
    math.format('hello')            // '"hello"'

@param {*} value             Value to be stringified
@param {Object | number | Function} [options]
    Formatting options. See src/utils/number.js:format for a
    description of the available options controlling number output.
    This generic "format" also supports the option property `truncate: NN`
    giving the maximum number NN of characters to return (if there would
    have been more, they are deleted and replaced by an ellipsis).
@return {string} str