shim.js 397 B

12345678910111213141516
  1. // Thanks: https://github.com/monolithed/ECMAScript-6
  2. "use strict";
  3. var exp = Math.exp;
  4. module.exports = function (value) {
  5. if (isNaN(value)) return NaN;
  6. value = Number(value);
  7. if (value === 0) return value;
  8. if (value === Infinity) return Infinity;
  9. if (value === -Infinity) return -1;
  10. if (value > -1.0e-6 && value < 1.0e-6) return value + (value * value) / 2;
  11. return exp(value) - 1;
  12. };