es.math.sinh.js 645 B

123456789101112131415161718192021
  1. var $ = require('../internals/export');
  2. var fails = require('../internals/fails');
  3. var expm1 = require('../internals/math-expm1');
  4. var abs = Math.abs;
  5. var exp = Math.exp;
  6. var E = Math.E;
  7. var FORCED = fails(function () {
  8. // eslint-disable-next-line es-x/no-math-sinh -- required for testing
  9. return Math.sinh(-2e-17) != -2e-17;
  10. });
  11. // `Math.sinh` method
  12. // https://tc39.es/ecma262/#sec-math.sinh
  13. // V8 near Chromium 38 has a problem with very small numbers
  14. $({ target: 'Math', stat: true, forced: FORCED }, {
  15. sinh: function sinh(x) {
  16. return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
  17. }
  18. });