<commit_before><link rel="import" href="../polymer/polymer.html">
<script type="text/javascript" src="../accounting/accounting.min.js"></script>
<script type="text/javascript">
(function () {
	'use strict';
	window.Cosmoz = window.Cosmoz || {};

	var formats = {
		EUR: {
			currency: {
				symbol: '€',   // default currency symbol is '$'
				format: '%s %v', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: '.',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		NOK: {
			currency: {
				symbol: 'kr',   // default currency symbol is '$'
				format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: ' ',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		SEK: {
			currency: {
				symbol: 'kr',   // default currency symbol is '$'
				format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: ' ',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		USD: {
			currency: {
				symbol: '$',   // default currency symbol is '$'
				format: '%s %v', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: '.',  // decimal point separator
				thousand: ',',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		ZAR: {
			currency: {
				symbol: 'ZAR',   // default currency symbol is '$'
				format: '%s %v', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: ' ',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ' ',
				decimal: ','
			}
		}
	};

	/**
	 * @polymerBehavior Cosmoz.MoneyHelperBehavior
	 * @demo
	 */
	Cosmoz.MoneyHelperBehavior = {
		renderAmount: function (money) {
			var format = this._renderFormat(money);
			return accounting.formatMoney(money.amount, format.currency);
		},
		renderMoney: function (money) {
			return this.renderAmount(money);
		},
		renderNumberAmount: function (money) {
			var format = this._renderFormat(money);
			return accounting.formatNumber(money.amount, format.currency);
		},
		unformatRenderedAmount: function (amountString, decimalSeparator) {
			return accounting.unformat(amountString, decimalSeparator === ',' ? ',' : '');
		},
		round: function (number, precision) {
			return parseFloat(accounting.toFixed(number, precision));
		},
		_renderFormat: function (money) {
			if (money === undefined) {
				return;
			}
			if (money.amount === undefined || money.currency === undefined) {
				return (money.amount === undefined
					? ''
					: money.amount) + ' ' + (money.currency === undefined
					? ''
					: money.currency);
			}
			var format = formats[money.currency];
			if (!format) {
				return money.amount + ' ' + money.currency;
			}
			return format;
		}
	};
}());
</script>
<commit_msg>moneyhelperbehavior - handle undefined/null args to renderAmount<commit_after><link rel="import" href="../polymer/polymer.html">
<script type="text/javascript" src="../accounting/accounting.min.js"></script>
<script type="text/javascript">
(function () {
	'use strict';
	window.Cosmoz = window.Cosmoz || {};

	var formats = {
		EUR: {
			currency: {
				symbol: '€',   // default currency symbol is '$'
				format: '%s %v', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: '.',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		NOK: {
			currency: {
				symbol: 'kr',   // default currency symbol is '$'
				format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: ' ',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		SEK: {
			currency: {
				symbol: 'kr',   // default currency symbol is '$'
				format: '%v %s', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: ' ',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		USD: {
			currency: {
				symbol: '$',   // default currency symbol is '$'
				format: '%s %v', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: '.',  // decimal point separator
				thousand: ',',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ',',
				decimal: '.'
			}
		},
		ZAR: {
			currency: {
				symbol: 'ZAR',   // default currency symbol is '$'
				format: '%s %v', // controls output: %s = symbol, %v = value/number (can be object: see below)
				decimal: ',',  // decimal point separator
				thousand: ' ',  // thousands separator
				precision: 2   // decimal places
			},
			number: {
				precision: 0,  // default precision on numbers is 0
				thousand: ' ',
				decimal: ','
			}
		}
	};

	/**
	 * @polymerBehavior Cosmoz.MoneyHelperBehavior
	 * @demo
	 */
	Cosmoz.MoneyHelperBehavior = {
		renderAmount(money) {
			if (money == null) {
				return;
			}
			const format = this._renderFormat(money);
			return accounting.formatMoney(money.amount, format.currency);
		},
		renderMoney: function (money) {
			return this.renderAmount(money);
		},
		renderNumberAmount: function (money) {
			var format = this._renderFormat(money);
			return accounting.formatNumber(money.amount, format.currency);
		},
		unformatRenderedAmount: function (amountString, decimalSeparator) {
			return accounting.unformat(amountString, decimalSeparator === ',' ? ',' : '');
		},
		round: function (number, precision) {
			return parseFloat(accounting.toFixed(number, precision));
		},
		_renderFormat: function (money) {
			if (money === undefined) {
				return;
			}
			if (money.amount === undefined || money.currency === undefined) {
				return (money.amount === undefined
					? ''
					: money.amount) + ' ' + (money.currency === undefined
					? ''
					: money.currency);
			}
			var format = formats[money.currency];
			if (!format) {
				return money.amount + ' ' + money.currency;
			}
			return format;
		}
	};
}());
</script>

{'fraction_non_alphanumeric': 0.15962570524287878, 'fraction_numerical': 0.004128250997660658, 'mean_word_length': 2.6968463886063074, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4310374', 'n_tokens_mistral': 2850, 'n_tokens_neox': 2219, 'n_words': 617}