How to use the traverse.reduce function in traverse

To help you get started, we’ve selected a few traverse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skidding / react-testing-examples / ui / webpack-loaders / readme-text-loader.js View on Github external
function getParagraphText(node) {
  return traverse.reduce(
    node.children,
    (text, node) => (isTextNode(node) ? text + node.value : text),
    ''
  );
}
github skidding / react-testing-examples / ui / webpack-loaders / readme-text-loader.js View on Github external
function getBody(nodes) {
  return traverse.reduce(
    nodes,
    (ps, node) => {
      return isParagraphNode(node) ? [...ps, getParagraphText(node)] : ps;
    },
    []
  );
}