lib/stringify.js
function stringifyArray(array, replacer, space, indent) {
  let childIndent = space ? (indent + space) : undefined;
  let str = space ? '[\n' : '[';

  // check for circular reference
  if (isCircular(array)) {
    return stringifyCircular(array, replacer, space, indent);
  }

  // add this array to the stack
  const stackIndex = stack.length;
  stack[stackIndex] = array;

  for (let i = 0; i < array.length; i++) {
    let key = i + '';
    let item = (typeof replacer === 'function')
        ? replacer.call(array, key, array[i])
        : array[i];

    if (space) {
      str += childIndent;
    }

    if (typeof item !== 'undefined' && typeof item !== 'function') {
      path[stackIndex] = key;
      str += stringifyValue(item, replacer, space, childIndent);
    }
    else {
      str += 'null'
    }

    if (i < array.length - 1) {
      str += space ? ',\n' : ',';
    }
  }

  // remove current entry from the stack
  stack.length = stackIndex;
  path.length = stackIndex;

  str += space ? ('\n' + indent + ']') : ']';
  return str;
}
function stringifyArray(array, replacer, space, indent) {
  let childIndent = space ? (indent + space) : undefined;
  let str = space ? '[\n' : '[';

  // check for circular reference
  if (isCircular(array)) {
    return stringifyCircular(array, replacer, space, indent);
  }

  // add this array to the stack
  const stackIndex = stack.length;
  stack[stackIndex] = array;

  for (let i = 0; i < array.length; i++) {
    let key = i + '';
    let item = (typeof replacer === 'function')
        ? replacer.call(array, key, array[i])
        : array[i];

    if (space) {
      str += childIndent;
    }

    if (typeof item !== 'undefined' && typeof item !== 'function') {
      path[stackIndex] = key;
      str += stringifyValue(item, replacer, space, childIndent);
    }
    else {
      str += 'null'
    }

    if (i < array.length - 1) {
      str += space ? ',\n' : ',';
    }
  }

  // remove current entry from the stack
  stack.length = stackIndex;
  path.length = stackIndex;

  str += space ? ('\n' + indent + ']') : ']';
  return str;
}
function stringifyArray ( array , replacer , space , indent ) { let childIndent = space ? ( indent + space ) : undefined ; let str = space ? '[\n' : '[' ; // check for circular reference if ( isCircular ( array ) ) { return stringifyCircular ( array , replacer , space , indent ) ; } // add this array to the stack const stackIndex = stack . length ; stack [ stackIndex ] = array ; for ( let i = 0 ; i < array . length ; i ++ ) { let key = i + '' ; let item = ( typeof replacer === 'function' ) ? replacer . call ( array , key , array [ i ] ) : array [ i ] ; if ( space ) { str += childIndent ; } if ( typeof item !== 'undefined' && typeof item !== 'function' ) { path [ stackIndex ] = key ; str += stringifyValue ( item , replacer , space , childIndent ) ; } else { str += 'null' } if ( i < array . length - 1 ) { str += space ? ',\n' : ',' ; } } // remove current entry from the stack stack . length = stackIndex ; path . length = stackIndex ; str += space ? ( '\n' + indent + ']' ) : ']' ; return str ; }
Stringify an array
@param {Array} array
@param {function | Array.<string | number>} [replacer]
@param {string} [space]
@param {string} [indent]
@return {string}
Stringify an array