summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/math/tanh/shim.js
blob: f6e948f2c53797ca3f05ab4bcf816c4a5e3f3d66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'use strict';

var exp = Math.exp;

module.exports = function (x) {
	var a, b;
	if (isNaN(x)) return NaN;
	x = Number(x);
	if (x === 0) return x;
	if (x === Infinity) return 1;
	if (x === -Infinity) return -1;
	a = exp(x);
	if (a === Infinity) return 1;
	b = exp(-x);
	if (b === Infinity) return -1;
	return (a - b) / (a + b);
};