stable.js
function stringifySimple (key, value, stack) {
  var i, res
  switch (typeof value) {
    case 'object':
      if (value === null) {
        return 'null'
      }
      if (typeof value.toJSON === 'function') {
        value = value.toJSON(key)
        // Prevent calling `toJSON` again
        if (typeof value !== 'object') {
          return stringifySimple(key, value, stack)
        }
        if (value === null) {
          return 'null'
        }
      }
      for (i = 0; i < stack.length; i++) {
        if (stack[i] === value) {
          return '"[Circular]"'
        }
      }

      if (Array.isArray(value)) {
        if (value.length === 0) {
          return '[]'
        }
        stack.push(value)
        res = '['
        // Use null as placeholder for non-JSON values.
        for (i = 0; i < value.length - 1; i++) {
          const tmp = stringifySimple(i, value[i], stack)
          res += tmp !== undefined ? tmp : 'null'
          res += ','
        }
        const tmp = stringifySimple(i, value[i], stack)
        res += tmp !== undefined ? tmp : 'null'
        res += ']'
        stack.pop()
        return res
      }

      const keys = insertSort(Object.keys(value))
      if (keys.length === 0) {
        return '{}'
      }
      stack.push(value)
      var separator = ''
      res = '{'
      for (i = 0; i < keys.length; i++) {
        key = keys[i]
        const tmp = stringifySimple(key, value[key], stack)
        if (tmp !== undefined) {
          res += `${separator}"${strEscape(key)}":${tmp}`
          separator = ','
        }
      }
      res += '}'
      stack.pop()
      return res
    case 'string':
      return `"${strEscape(value)}"`
    case 'number':
      // JSON numbers must be finite. Encode non-finite numbers as null.
      // Convert the numbers implicit to a string instead of explicit.
      return isFinite(value) ? String(value) : 'null'
    case 'boolean':
      return value === true ? 'true' : 'false'
  }
}
function stringifySimple (key, value, stack) {
  var i, res
  switch (typeof value) {
    case 'object':
      if (value === null) {
        return 'null'
      }
      if (typeof value.toJSON === 'function') {
        value = value.toJSON(key)
        // Prevent calling `toJSON` again
        if (typeof value !== 'object') {
          return stringifySimple(key, value, stack)
        }
        if (value === null) {
          return 'null'
        }
      }
      for (i = 0; i < stack.length; i++) {
        if (stack[i] === value) {
          return '"[Circular]"'
        }
      }

      if (Array.isArray(value)) {
        if (value.length === 0) {
          return '[]'
        }
        stack.push(value)
        res = '['
        // Use null as placeholder for non-JSON values.
        for (i = 0; i < value.length - 1; i++) {
          const tmp = stringifySimple(i, value[i], stack)
          res += tmp !== undefined ? tmp : 'null'
          res += ','
        }
        const tmp = stringifySimple(i, value[i], stack)
        res += tmp !== undefined ? tmp : 'null'
        res += ']'
        stack.pop()
        return res
      }

      const keys = insertSort(Object.keys(value))
      if (keys.length === 0) {
        return '{}'
      }
      stack.push(value)
      var separator = ''
      res = '{'
      for (i = 0; i < keys.length; i++) {
        key = keys[i]
        const tmp = stringifySimple(key, value[key], stack)
        if (tmp !== undefined) {
          res += `${separator}"${strEscape(key)}":${tmp}`
          separator = ','
        }
      }
      res += '}'
      stack.pop()
      return res
    case 'string':
      return `"${strEscape(value)}"`
    case 'number':
      // JSON numbers must be finite. Encode non-finite numbers as null.
      // Convert the numbers implicit to a string instead of explicit.
      return isFinite(value) ? String(value) : 'null'
    case 'boolean':
      return value === true ? 'true' : 'false'
  }
}
function stringifySimple ( key , value , stack ) { var i , res switch ( typeof value ) { case 'object' : if ( value === null ) { return 'null' } if ( typeof value . toJSON === 'function' ) { value = value . toJSON ( key ) // Prevent calling `toJSON` again if ( typeof value !== 'object' ) { return stringifySimple ( key , value , stack ) } if ( value === null ) { return 'null' } } for ( i = 0 ; i < stack . length ; i ++ ) { if ( stack [ i ] === value ) { return '"[Circular]"' } } if ( Array . isArray ( value ) ) { if ( value . length === 0 ) { return '[]' } stack . push ( value ) res = '[' // Use null as placeholder for non-JSON values. for ( i = 0 ; i < value . length - 1 ; i ++ ) { const tmp = stringifySimple ( i , value [ i ] , stack ) res += tmp !== undefined ? tmp : 'null' res += ',' } const tmp = stringifySimple ( i , value [ i ] , stack ) res += tmp !== undefined ? tmp : 'null' res += ']' stack . pop ( ) return res } const keys = insertSort ( Object . keys ( value ) ) if ( keys . length === 0 ) { return '{}' } stack . push ( value ) var separator = '' res = '{' for ( i = 0 ; i < keys . length ; i ++ ) { key = keys [ i ] const tmp = stringifySimple ( key , value [ key ] , stack ) if ( tmp !== undefined ) { res += ` ${ separator } ${ strEscape ( key ) } ${ tmp } ` separator = ',' } } res += '}' stack . pop ( ) return res case 'string' : return ` ${ strEscape ( value ) } ` case 'number' : // JSON numbers must be finite. Encode non-finite numbers as null. // Convert the numbers implicit to a string instead of explicit. return isFinite ( value ) ? String ( value ) : 'null' case 'boolean' : return value === true ? 'true' : 'false' } }
Simple without any options
Simple without any options