function format(currency, settings) {
  let { pattern, negativePattern, symbol, separator, decimal, groups } = settings
    , split = ('' + currency).replace(/^-/, '').split('.')
    , dollars = split[0]
    , cents = split[1];

  return (currency.value >= 0 ? pattern : negativePattern)
    .replace('!', symbol)
    .replace('#', dollars.replace(groups, '$1' + separator) + (cents ? decimal + cents : ''));
}
Formats a currency object
@param currency
@param {object} [opts]