aquaform/project-lvl2-s96

View on GitHub
src/strategies/renderAstToJSON.js

Summary

Maintainability
A
0 mins
Test Coverage
const replacer = (key, value) => {
  if (key === 'children' && value.length === 0) {
    return undefined;
  }

  return value;
};

const renderAstToJSON = ast => JSON.stringify(ast, replacer, 2);

export default renderAstToJSON;