lib/stringify.js
function stringify(data, visitor, indent) {
  if (typeof data === 'function' || typeof data === 'undefined') {
    // eslint-disable-next-line consistent-return
    return undefined;
  }

  indent = parseIndent(indent);

  const normalized = JSON.parse(JSON.stringify(data, visitor));

  function visitNode(node, options) {
    if (options == null) {
      options = {};
    }

    switch (typeof node) {
      case 'boolean':
        return `${node}`;

      case 'number':
        if (isFinite(node)) {
          return `${node}`;
        }
        return 'null';

      case 'string':
        return visitString(visitNode, indent, node, options);

      case 'object':
        if (node === null) {
          return 'null';
        } else if (Array.isArray(node)) {
          return visitArray(visitNode, indent, node, options);
        }
        return visitObject(visitNode, indent, node, options);

      default:
        // eslint-disable-next-line consistent-return
        return undefined;
    }
  }

  // eslint-disable-next-line consistent-return
  return visitNode(normalized);
}
function stringify(data, visitor, indent) {
  if (typeof data === 'function' || typeof data === 'undefined') {
    // eslint-disable-next-line consistent-return
    return undefined;
  }

  indent = parseIndent(indent);

  const normalized = JSON.parse(JSON.stringify(data, visitor));

  function visitNode(node, options) {
    if (options == null) {
      options = {};
    }

    switch (typeof node) {
      case 'boolean':
        return `${node}`;

      case 'number':
        if (isFinite(node)) {
          return `${node}`;
        }
        return 'null';

      case 'string':
        return visitString(visitNode, indent, node, options);

      case 'object':
        if (node === null) {
          return 'null';
        } else if (Array.isArray(node)) {
          return visitArray(visitNode, indent, node, options);
        }
        return visitObject(visitNode, indent, node, options);

      default:
        // eslint-disable-next-line consistent-return
        return undefined;
    }
  }

  // eslint-disable-next-line consistent-return
  return visitNode(normalized);
}
function stringify ( data , visitor , indent ) { if ( typeof data === 'function' || typeof data === 'undefined' ) { // eslint-disable-next-line consistent-return return undefined ; } indent = parseIndent ( indent ) ; const normalized = JSON . parse ( JSON . stringify ( data , visitor ) ) ; function visitNode ( node , options ) { if ( options == null ) { options = { } ; } switch ( typeof node ) { case 'boolean' : return ` ${ node } ` ; case 'number' : if ( isFinite ( node ) ) { return ` ${ node } ` ; } return 'null' ; case 'string' : return visitString ( visitNode , indent , node , options ) ; case 'object' : if ( node === null ) { return 'null' ; } else if ( Array . isArray ( node ) ) { return visitArray ( visitNode , indent , node , options ) ; } return visitObject ( visitNode , indent , node , options ) ; default : // eslint-disable-next-line consistent-return return undefined ; } } // eslint-disable-next-line consistent-return return visitNode ( normalized ) ; }
disabling consistent return so cson parser handles undefined like JSON.stringify does
disabling consistent return so cson parser handles undefined like JSON . stringify does