<commit_before>var module = angular.module('filters', []),
    webutil = require('../util/web'),
    Amount = ripple.Amount;

var iso4217 = require('../data/iso4217');

/**
 * Format a ripple.Amount.
 *
 * If the parameter is a number, the number is treated the relative 
 */
module.filter('rpamount', function () {
  return function (input, opts) {
    if ("number" === typeof opts) {
      opts = {
        rel_min_precision: opts
      };
    } else if ("object" !== typeof opts) {
      opts = {};
    }

    if (!input) return "n/a";

    var amount = Amount.from_json(input);
    if (!amount.is_valid()) return "n/a";

    // Currency default precision
    var currency = iso4217[amount.currency().to_json()];
    var cdp = ("undefined" !== typeof currency) ? currency[1] : 2;

    // Certain formatting options are relative to the currency default precision
    if ("number" === typeof opts.rel_precision) {
      opts.precision = cdp + opts.rel_precision;
    }
    if ("number" === typeof opts.rel_min_precision) {
      opts.min_precision = cdp + opts.rel_min_precision;
    }

    // If no precision is given, we'll default to max precision.
    if ("number" !== typeof opts.precision) {
      opts.precision = 16;
    }

    var out = amount.to_human(opts);

    return out;<commit_msg>Rpamount filter: Currency default precision set to 4<commit_after>var module = angular.module('filters', []),
    webutil = require('../util/web'),
    Amount = ripple.Amount;

var iso4217 = require('../data/iso4217');

/**
 * Format a ripple.Amount.
 *
 * If the parameter is a number, the number is treated the relative 
 */
module.filter('rpamount', function () {
  return function (input, opts) {
    if ("number" === typeof opts) {
      opts = {
        rel_min_precision: opts
      };
    } else if ("object" !== typeof opts) {
      opts = {};
    }

    if (!input) return "n/a";

    var amount = Amount.from_json(input);
    if (!amount.is_valid()) return "n/a";

    // Currency default precision
    var currency = iso4217[amount.currency().to_json()];
    var cdp = ("undefined" !== typeof currency) ? currency[1] : 4;

    // Certain formatting options are relative to the currency default precision
    if ("number" === typeof opts.rel_precision) {
      opts.precision = cdp + opts.rel_precision;
    }
    if ("number" === typeof opts.rel_min_precision) {
      opts.min_precision = cdp + opts.rel_min_precision;
    }

    // If no precision is given, we'll default to max precision.
    if ("number" !== typeof opts.precision) {
      opts.precision = 16;
    }

    var out = amount.to_human(opts);

    return out;
{'fraction_non_alphanumeric': 0.14383301707779886, 'fraction_numerical': 0.012523719165085389, 'mean_word_length': 2.8202898550724638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '485017', 'n_tokens_mistral': 855, 'n_tokens_neox': 788, 'n_words': 232}