shim.js 443 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 (value) {
  5. if (isNaN(value)) return NaN;
  6. value = Number(value);
  7. if (value < -1) return NaN;
  8. if (value === -1) return -Infinity;
  9. if (value === 0) return value;
  10. if (value === Infinity) return Infinity;
  11. if (value > -1.0e-8 && value < 1.0e-8) return value - value * value / 2;
  12. return log(1 + value);
  13. };