// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
-import { call } from "./function.js";
+import { call, createArrowFunction } from "./function.js";
import {
stringCatenate,
stringPadEnd,
*/
SQRT2,
- /**
- * Returns the arccos of the provided value.
- *
- * ※ This is an alias for `Math.acos`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- acos: arccos,
-
- /**
- * Returns the arccosh of the provided value.
- *
- * ※ This is an alias for `Math.acosh`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- acosh: arccosh,
-
- /**
- * Returns the arcsin of the provided value.
- *
- * ※ This is an alias for `Math.asin`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- asin: arcsin,
-
- /**
- * Returns the arcsinh of the provided value.
- *
- * ※ This is an alias for `Math.asinh`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- asinh: arcsinh,
-
- /**
- * Returns the arctan of the provided value.
- *
- * ※ This is an alias for `Math.atan`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- atan: arctan,
-
- /**
- * Returns the arctanh of the provided value.
- *
- * ※ This is an alias for `Math.atanh`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- atanh: arctanh,
-
- /**
- * Returns the cube root of the provided value.
- *
- * ※ This is an alias for `Math.cbrt`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- cbrt,
-
- /**
- * Returns the ceiling of the provided value.
- *
- * ※ This is an alias for `Math.ceil`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- ceil,
-
- /**
- * Returns the cos of the provided value.
- *
- * ※ This is an alias for `Math.cos`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- cos,
-
- /**
- * Returns the cosh of the provided value.
- *
- * ※ This is an alias for `Math.cosh`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- cosh,
-
- /**
- * Returns the Euler number raised to the provided value.
- *
- * ※ This is an alias for `Math.exp`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- exp,
-
- /**
- * Returns the Euler number raised to the provided value, minus one.
- *
- * ※ This is an alias for `Math.expm1`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- expm1,
-
- /**
- * Returns the floor of the provided value.
- *
- * ※ This is an alias for `Math.floor`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- floor,
-
- /**
- * Returns the square root of the sum of the squares of the provided
- * arguments.
- *
- * ※ This is an alias for `Math.hypot`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- hypot,
-
- /**
- * Returns the ln of the provided value.
- *
- * ※ This is an alias for `Math.log`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- log: ln,
-
- /**
- * Returns the log10 of the provided value.
- *
- * ※ This is an alias for `Math.log10`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- log10,
-
- /**
- * Returns the ln of one plus the provided value.
- *
- * ※ This is an alias for `Math.log1p`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- log1p: ln1p,
-
- /**
- * Returns the log2 of the provided value.
- *
- * ※ This is an alias for `Math.log2`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- log2,
-
- /**
- * Returns a pseudo·random value in the range [0, 1).
- *
- * ※ This is an alias for `Math.random`.
- */
- random: rand,
-
- /**
- * Returns the round of the provided value.
- *
- * ※ This is an alias for `Math.round`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- round,
-
- /**
- * Returns the sinh of the provided value.
- *
- * ※ This is an alias for `Math.sinh`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- sinh,
-
- /**
- * Returns the square root of the provided value.
- *
- * ※ This is an alias for `Math.sqrt`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- sqrt,
-
- /**
- * Returns the tan of the provided value.
- *
- * ※ This is an alias for `Math.tan`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- tan,
-
- /**
- * Returns the tanh of the provided value.
- *
- * ※ This is an alias for `Math.tanh`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- tanh,
-
- /**
- * Returns the trunc of the provided value.
- *
- * ※ This is an alias for `Math.trunc`.
- *
- * ☡ This function does not allow big·int arguments.
- */
- trunc,
-
/**
* The mathematical constant π.
*
* ※ This is an alias for `Number.EPSILON`.
*/
EPSILON: Ε,
-
- /**
- * Returns whether the provided value is a finite number.
- *
- * ※ This is an alias for `Number.isFinite`.
- */
- isFinite: isFiniteNumber,
-
- /**
- * Returns whether the provided value is an integral number.
- *
- * ※ This is an alias for `Number.isInteger`.
- */
- isInteger: isIntegralNumber,
-
- /**
- * Returns whether the provided value is nan.
- *
- * ※ This is an alias for `Number.isNaN`.
- */
- isNaN: isNan,
-
- /**
- * Returns whether the provided value is a safe integral number.
- *
- * ※ This is an alias for `Number.isSafeInteger`.
- */
- isSafeInteger: isSafeIntegralNumber,
} = Number;
-/** Positive zero. */
-export const POSITIVE_ZERO = 0;
-
/** Negative zero. */
export const NEGATIVE_ZERO = -0;
+/** Positive zero. */
+export const POSITIVE_ZERO = 0;
+
/**
* Returns the magnitude (absolute value) of the provided value.
*
: n;
};
+/**
+ * Returns the arccos of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.acos`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const arccos = createArrowFunction(
+ Math.acos,
+ { name: "arccos" },
+);
+
+/**
+ * Returns the arccosh of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.acosh`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const arccosh = createArrowFunction(
+ Math.acosh,
+ { name: "arccosh" },
+);
+
+/**
+ * Returns the arcsin of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.asin`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const arcsin = createArrowFunction(
+ Math.asin,
+ { name: "arcsin" },
+);
+
+/**
+ * Returns the arcsinh of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.asinh`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const arcsinh = createArrowFunction(
+ Math.asinh,
+ { name: "arcsinh" },
+);
+
+/**
+ * Returns the arctan of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.atan`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const arctan = createArrowFunction(
+ Math.atan,
+ { name: "arctan" },
+);
+
export const {
/**
* Returns the arctangent of the dividend of the provided values.
* ※ Unlike `Math.atan2`, this function can take big·int arguments.
* However, the result will always be a number.
*/
- atan2,
+ arctan2,
/**
* Returns the number of leading zeroes in the 32‐bit representation
} = (() => {
const { atan2, fround, clz32 } = Math;
return {
- atan2: (y, x) => atan2(toNumber(y), toNumber(x)),
+ arctan2: (y, x) => atan2(toNumber(y), toNumber(x)),
clz32: ($) => {
const n = toNumeric($);
return clz32(
};
})();
+/**
+ * Returns the arctanh of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.atanh`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const arctanh = createArrowFunction(
+ Math.atanh,
+ { name: "arctanh" },
+);
+
+/**
+ * Returns the cube root of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.cbrt`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const cbrt = createArrowFunction(Math.cbrt);
+
+/**
+ * Returns the ceiling of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.ceil`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const ceil = createArrowFunction(Math.ceil);
+
+/**
+ * Returns the cos of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.cos`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const cos = createArrowFunction(Math.cos);
+
+/**
+ * Returns the cosh of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.cosh`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const cosh = createArrowFunction(Math.cosh);
+
+/**
+ * Returns the Euler number raised to the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.exp`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const exp = createArrowFunction(Math.exp);
+
+/**
+ * Returns the Euler number raised to the provided value, minus one.
+ *
+ * ※ This function is effectively an alias for `Math.expm1`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const expm1 = createArrowFunction(Math.expm1);
+
+/**
+ * Returns the floor of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.floor`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const floor = createArrowFunction(Math.floor);
+
+/**
+ * Returns the square root of the sum of the squares of the provided
+ * arguments.
+ *
+ * ※ This function is effectively an alias for `Math.hypot`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const hypot = createArrowFunction(Math.hypot);
+
+/**
+ * Returns whether the provided value is a finite number.
+ *
+ * ※ This function is effectively an alias for `Number.isFinite`.
+ */
+export const isFiniteNumber = createArrowFunction(
+ Number.isFinite,
+ { name: "isFiniteNumber" },
+);
+
+/**
+ * Returns whether the provided value is an integral number.
+ *
+ * ※ This function is effectively an alias for `Number.isInteger`.
+ */
+export const isIntegralNumber = createArrowFunction(
+ Number.isInteger,
+ { name: "isIntegralNumber" },
+);
+
+/**
+ * Returns whether the provided value is nan.
+ *
+ * ※ This function is effectively an alias for `Number.isNaN`.
+ */
+export const isNan = createArrowFunction(
+ Number.isNaN,
+ { name: "isNan" },
+);
+
+/**
+ * Returns whether the provided value is a safe integral number.
+ *
+ * ※ This function is effectively an alias for `Number.isSafeInteger`.
+ */
+export const isSafeIntegralNumber = createArrowFunction(
+ Number.isSafeInteger,
+ { name: "isSafeIntegralNumber" },
+);
+
+/**
+ * Returns the ln of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.log`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const ln = createArrowFunction(Math.log, { name: "ln" });
+
+/**
+ * Returns the ln of one plus the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.log1p`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const ln1p = createArrowFunction(Math.log1p, { name: "ln1p" });
+
+/**
+ * Returns the log10 of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.log10`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const log10 = createArrowFunction(Math.log10);
+
+/**
+ * Returns the log2 of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.log2`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const log2 = createArrowFunction(Math.log2);
+
/**
* Returns the highest value of the provided arguments, or negative
* infinity if no argument is provided.
* ☡ If no argument is supplied, the result will be a number, not a
* big·int.
*/
-export const max = (...$s) => {
+export const max = Object.defineProperties((...$s) => {
let highest = undefined;
for (let i = 0; i < $s.length; ++i) {
// Iterate over all the numbers.
}
}
return highest ?? NEGATIVE_INFINITY;
-};
+}, { name: { value: "max" }, length: { value: 2 } });
/**
* Returns the lowest value of the provided arguments, or positive
* ☡ If no argument is supplied, the result will be a number, not a
* big·int.
*/
-export const min = (...$s) => {
+export const min = Object.defineProperties((...$s) => {
let lowest = undefined;
for (let i = 0; i < $s.length; ++i) {
// Iterate over all the numbers.
}
}
return lowest ?? POSITIVE_INFINITY;
-};
+}, { name: { value: "min" }, length: { value: 2 } });
+
+/**
+ * Returns a pseudo·random value in the range [0, 1).
+ *
+ * ※ This function is effectively an alias for `Math.random`.
+ */
+export const rand = createArrowFunction(
+ Math.random,
+ { name: "rand" },
+);
+
+/**
+ * Returns the round of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.round`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const round = createArrowFunction(Math.round);
/**
* Returns a unit value with the same sign as the provided value, or
: 1;
};
+/**
+ * Returns the sin of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.sin`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const sin = createArrowFunction(Math.sin);
+
+/**
+ * Returns the sinh of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.sinh`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const sinh = createArrowFunction(Math.sinh);
+
+/**
+ * Returns the square root of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.sqrt`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const sqrt = createArrowFunction(Math.sqrt);
+
+/**
+ * Returns the tan of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.tan`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const tan = createArrowFunction(Math.tan);
+
+/**
+ * Returns the tanh of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.tanh`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const tanh = createArrowFunction(Math.tanh);
+
/**
* Returns the result of converting the provided value to a big·int.
*
},
};
})();
+
+/**
+ * Returns the trunc of the provided value.
+ *
+ * ※ This function is effectively an alias for `Math.trunc`.
+ *
+ * ☡ This function does not allow big·int arguments.
+ */
+export const trunc = createArrowFunction(Math.trunc);