bps.umd.js 863 Bytes
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global.numerifyBps = factory());
}(this, (function () { 'use strict';

  var bps = {
    regexp: /BPS/,
    format: function format(value, formatType, roundingFunction, numerify) {
      var space = ~formatType.indexOf(' BPS') ? ' ' : '';
      value = value * 10000;
      formatType = formatType.replace(/\s?BPS/, '');
      var output = numerify._numberToFormat(value, formatType, roundingFunction);

      if (!output.indexOf(')')) {
        output = output.split('');
        output.splice(-1, 0, space + 'BPS');
        output = output.join('');
      } else {
        output = output + space + 'BPS';
      }

      return output;
    }
  };

  return bps;

})));