es.math.atanh.js 481 B

123456789101112131415161718
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. // eslint-disable-next-line es/no-math-atanh -- required for testing
  4. var $atanh = Math.atanh;
  5. var log = Math.log;
  6. var FORCED = !($atanh && 1 / $atanh(-0) < 0);
  7. // `Math.atanh` method
  8. // https://tc39.es/ecma262/#sec-math.atanh
  9. // Tor Browser bug: Math.atanh(-0) -> 0
  10. $({ target: 'Math', stat: true, forced: FORCED }, {
  11. atanh: function atanh(x) {
  12. var n = +x;
  13. return n === 0 ? n : log((1 + n) / (1 - n)) / 2;
  14. }
  15. });