// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
import { call, createArrowFunction } from "./function.js";
+import { defineOwnDataProperty } from "./object.js";
import {
stringCatenate,
stringPadEnd,
POSITIVE_INFINITY,
sameValue,
toPrimitive,
+ UNDEFINED,
} from "./value.js";
/**
* big·int.
*/
export const max = Object.defineProperties((...$s) => {
- let highest = undefined;
+ let highest = UNDEFINED;
for (let i = 0; i < $s.length; ++i) {
// Iterate over all the numbers.
const number = toNumeric($s[i]);
- if (highest === undefined) {
+ if (highest === UNDEFINED) {
// The current number is the first one.
if (isNan(number)) {
// The current number is nan.
} else if (sameValue(number, 0) && sameValue(highest, -0)) {
// The current number is +0 and the highest number is -0.
highest = 0;
- } else if (highest === undefined || number > highest) {
+ } else if (number > highest) {
// The current number is greater than the highest number.
highest = number;
} else {
}
}
return highest ?? NEGATIVE_INFINITY;
-}, { name: { value: "max" }, length: { value: 2 } });
+}, {
+ name: defineOwnDataProperty(Object.create(null), "value", "max"),
+ length: defineOwnDataProperty(Object.create(null), "value", 2),
+});
/**
* Returns the lowest value of the provided arguments, or positive
* big·int.
*/
export const min = Object.defineProperties((...$s) => {
- let lowest = undefined;
+ let lowest = UNDEFINED;
for (let i = 0; i < $s.length; ++i) {
// Iterate over all the numbers.
const number = toNumeric($s[i]);
- if (lowest === undefined) {
+ if (lowest === UNDEFINED) {
// The current number is the first one.
if (isNan(number)) {
// The current number is nan.
}
}
return lowest ?? POSITIVE_INFINITY;
-}, { name: { value: "min" }, length: { value: 2 } });
+}, {
+ name: defineOwnDataProperty(Object.create(null), "value", "min"),
+ length: defineOwnDataProperty(Object.create(null), "value", 2),
+});
/**
* Returns a pseudo·random value in the range [0, 1).
return call(
numberToExponential,
n,
- [fractionDigits === undefined ? fractionDigits : f],
+ [fractionDigits === UNDEFINED ? fractionDigits : f],
);
} else {
const digits = call(bigintToString, n, [10]);
const { length } = digits;
- if (fractionDigits === undefined) {
+ if (fractionDigits === UNDEFINED) {
return length === 1
? `${digits[0]}e+0`
: `${digits[0]}.${substring(digits, 1)}e+${length - 1}`;