Utils.js 587 Bytes
Newer Older
d.arizona's avatar
d.arizona committed
1 2 3 4
export function titleCase(text) {
	var value = String(text).replace(/\./g, ' ')
		.replace(/\s/g, ' ')
		.replace(/^(.)/, function($1) { return $1.toUpperCase(); })
qorri_di's avatar
qorri_di committed
5
	// .replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
d.arizona's avatar
d.arizona committed
6 7

	return value
syadziy's avatar
syadziy committed
8 9 10 11 12
}

export function roundMath(number, decimalPlaces) {
	const factorOfTen = Math.pow(10, decimalPlaces)
  	return Math.round(number * factorOfTen) / factorOfTen
qorri_di's avatar
qorri_di committed
13 14 15 16 17
}

export function fixNumber(num, decimalCount = 2) {
	const output = Math.round((num + Number.EPSILON) * (Math.pow(10,decimalCount))) / (Math.pow(10,decimalCount))
	return output
d.arizona's avatar
d.arizona committed
18
}