shim.js 289 B

1234567891011121314
  1. 'use strict';
  2. var log = Math.log;
  3. module.exports = function (x) {
  4. if (isNaN(x)) return NaN;
  5. x = Number(x);
  6. if (x < -1) return NaN;
  7. if (x > 1) return NaN;
  8. if (x === -1) return -Infinity;
  9. if (x === 1) return Infinity;
  10. if (x === 0) return x;
  11. return 0.5 * log((1 + x) / (1 - x));
  12. };