lib/stringify.js
function stringifyValue(value, replacer, space, indent) {
  // boolean, null, number, string, or date
  if (typeof value === 'boolean' || value instanceof Boolean ||
      value === null ||
      typeof value === 'number' || value instanceof Number ||
      typeof value === 'string' || value instanceof String ||
      value instanceof Date) {
    return JSON.stringify(value);
  }

  // lossless number, the secret ingredient :)
  if (value && value.isLosslessNumber) {
    return value.value;
  }

  // array
  if (Array.isArray(value)) {
    return stringifyArray(value, replacer, space, indent);
  }

  // object (test lastly!)
  if (value && typeof value === 'object') {
    return stringifyObject(value, replacer, space, indent);
  }

  return undefined;
}
function stringifyValue(value, replacer, space, indent) {
  // boolean, null, number, string, or date
  if (typeof value === 'boolean' || value instanceof Boolean ||
      value === null ||
      typeof value === 'number' || value instanceof Number ||
      typeof value === 'string' || value instanceof String ||
      value instanceof Date) {
    return JSON.stringify(value);
  }

  // lossless number, the secret ingredient :)
  if (value && value.isLosslessNumber) {
    return value.value;
  }

  // array
  if (Array.isArray(value)) {
    return stringifyArray(value, replacer, space, indent);
  }

  // object (test lastly!)
  if (value && typeof value === 'object') {
    return stringifyObject(value, replacer, space, indent);
  }

  return undefined;
}
function stringifyValue ( value , replacer , space , indent ) { // boolean, null, number, string, or date if ( typeof value === 'boolean' || value instanceof Boolean || value === null || typeof value === 'number' || value instanceof Number || typeof value === 'string' || value instanceof String || value instanceof Date ) { return JSON . stringify ( value ) ; } // lossless number, the secret ingredient :) if ( value && value . isLosslessNumber ) { return value . value ; } // array if ( Array . isArray ( value ) ) { return stringifyArray ( value , replacer , space , indent ) ; } // object (test lastly!) if ( value && typeof value === 'object' ) { return stringifyObject ( value , replacer , space , indent ) ; } return undefined ; }
Stringify a value
@param {*} value
@param {function | Array.<string | number>} [replacer]
@param {string} [space]
@param {string} [indent]
@return {string | undefined}
Stringify a value