'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _lodash = require('lodash');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var trimZeroes = function trimZeroes(str) {
  if (str[str.length - 1] === '0') {
    return trimZeroes(str.slice(0, -1));
  } else if (str.indexOf('.') > str.length - 2) {}
  return (0, _lodash.padEnd)(str, 2, '0');
};

exports.default = function (money) {
  if (typeof money === 'string' || typeof money === 'number') {
    var _split = ('' + money).split('.'),
        _split2 = (0, _slicedToArray3.default)(_split, 2),
        dollars = _split2[0],
        cents = _split2[1];

    return dollars + '.' + trimZeroes((cents || '00') + '00');
  }
  // we don't recognize this money type...
  return money;
};