index.js
function walk(x, action, format, meta) {
  if (Array.isArray(x)) {
    var array = [];
    x.forEach(function (item) {
      if (item === Object(item) && item.t) {
        var res = action(item.t, item.c || [], format, meta)
        if (!res) {
          array.push(walk(item, action, format, meta));
        }
        else if (Array.isArray(res)) {
          res.forEach(function (z) {
            array.push(walk(z, action, format, meta));
          });
        }
        else {
          array.push(walk(res, action, format, meta));
        }
      }
      else {
        array.push(walk(item, action, format, meta));
      }
    });
    return array;
  }
  else if (x === Object(x)) {
    var obj = {};
    Object.keys(x).forEach(function (k) {
      obj[k] = walk(x[k], action, format, meta);
    });
    return obj;
  }
  return x;
}
function walk(x, action, format, meta) {
  if (Array.isArray(x)) {
    var array = [];
    x.forEach(function (item) {
      if (item === Object(item) && item.t) {
        var res = action(item.t, item.c || [], format, meta)
        if (!res) {
          array.push(walk(item, action, format, meta));
        }
        else if (Array.isArray(res)) {
          res.forEach(function (z) {
            array.push(walk(z, action, format, meta));
          });
        }
        else {
          array.push(walk(res, action, format, meta));
        }
      }
      else {
        array.push(walk(item, action, format, meta));
      }
    });
    return array;
  }
  else if (x === Object(x)) {
    var obj = {};
    Object.keys(x).forEach(function (k) {
      obj[k] = walk(x[k], action, format, meta);
    });
    return obj;
  }
  return x;
}
function walk ( x , action , format , meta ) { if ( Array . isArray ( x ) ) { var array = [ ] ; x . forEach ( function ( item ) { if ( item === Object ( item ) && item . t ) { var res = action ( item . t , item . c || [ ] , format , meta ) if ( ! res ) { array . push ( walk ( item , action , format , meta ) ) ; } else if ( Array . isArray ( res ) ) { res . forEach ( function ( z ) { array . push ( walk ( z , action , format , meta ) ) ; } ) ; } else { array . push ( walk ( res , action , format , meta ) ) ; } } else { array . push ( walk ( item , action , format , meta ) ) ; } } ) ; return array ; } else if ( x === Object ( x ) ) { var obj = { } ; Object . keys ( x ) . forEach ( function ( k ) { obj [ k ] = walk ( x [ k ] , action , format , meta ) ; } ) ; return obj ; } return x ; }
Walk a tree, applying an action to every object.
@param  {Object}   x      The object to traverse
@param  {Function} action Callback to apply to each item
@param  {String}   format Output format
@param  {Object}   meta   Pandoc metadata
@return {Object}          The modified tree
Walk a tree applying an action to every object .