UNPKG

724 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.pows = exports.logs = void 0;
4const reflect = (f) => {
5 return (x) => -f(-x);
6};
7const logs = (base, shouldReflect) => {
8 const baseCache = Math.log(base);
9 const log = base === Math.E
10 ? Math.log
11 : base === 10
12 ? Math.log10
13 : base === 2
14 ? Math.log2
15 : (x) => Math.log(x) / baseCache;
16 return shouldReflect ? reflect(log) : log;
17};
18exports.logs = logs;
19const pows = (base, shouldReflect) => {
20 const pow = base === Math.E ? Math.exp : (x) => base ** x;
21 return shouldReflect ? reflect(pow) : pow;
22};
23exports.pows = pows;
24//# sourceMappingURL=log.js.map
\No newline at end of file