2
0

shim.js 343 B

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