shim.js 350 B

123456789101112131415
  1. "use strict";
  2. var log = Math.log, sqrt = Math.sqrt;
  3. module.exports = function (value) {
  4. if (isNaN(value)) return NaN;
  5. value = Number(value);
  6. if (value === 0) return value;
  7. if (!isFinite(value)) return value;
  8. if (value < 0) {
  9. value = -value;
  10. return -log(value + sqrt(value * value + 1));
  11. }
  12. return log(value + sqrt(value * value + 1));
  13. };