1
0

shim.js 385 B

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