code: function transactionFilter(transactions, options) {
    var filtered_transactions = transactions.filter(function(transaction) {
      if (options.exclude_failed) {
        if (transaction.state === 'failed' || (transaction.meta
            && transaction.meta.TransactionResult !== 'tesSUCCESS')) {
          return false;
        }
      }
      if (options.types && options.types.length > 0) {
        if (options.types.indexOf(
            transaction.TransactionType.toLowerCase()) === -1) {
          return false;
        }
      }
      if (options.source_account) {
        if (transaction.Account !== options.source_account) {
          return false;
        }
      }
      if (options.destination_account) {
        if (transaction.Destination !== options.destination_account) {
          return false;
        }
      }
      if (options.direction) {
        if (options.direction === 'outgoing'
            && transaction.Account !== options.account) {
          return false;
        }
        if (options.direction === 'incoming' && transaction.Destination
            && transaction.Destination !== options.account) {
          return false;
        }
      }
      return true;
    });
  
    return filtered_transactions;
  }
docs: Filter transactions based on the given set of options.
  
  @param {Array of transactions in JSON format} transactions
  @param {Boolean} [false] options.exclude_failed
  @param {Array of Strings} options.types Possible values are "payment",
  "offercreate", "offercancel", "trustset", "accountset"
  @param {RippleAddress} options.source_account
  @param {RippleAddress} options.destination_account
  @param {String} options.direction Possible values are "incoming", "outgoing"
  
  @returns {Array of transactions in JSON format} filtered_transactions