exponential.umd.js 851 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
(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global.numerifyExponential = factory());
}(this, (function () { 'use strict';

  function numIsNaN(value) {
    return typeof value === 'number' && isNaN(value);
  }

  var exponential = {
    regexp: /(e\+|e-)/,
    format: function format(value, formatType, roundingFunction, numerify) {
      var exponential = typeof value === 'number' && !numIsNaN(value) ? value.toExponential() : '0e+0';
      var parts = exponential.split('e');
      formatType = formatType.replace(/e[+|-]{1}0/, '');
      var output = numerify._numberToFormat(+parts[0], formatType, roundingFunction);

      return output + 'e' + parts[1];
    }
  };

  return exponential;

})));