substring,
toString,
} from "./string.js";
-import { sameValue, toPrimitive } from "./value.js";
-
-export const {
- /**
- * ln(10).
- *
- * ※ This is an alias for `Math.LN10`.
- */
- LN10,
-
- /**
- * ln(2).
- *
- * ※ This is an alias for `Math.LN2`.
- */
- LN2,
-
- /**
- * log10(ℇ).
- *
- * ※ This is an alias for `Math.LOG10E`.
- */
- LOG10E: LOG10ℇ,
-
- /**
- * log2(ℇ).
- *
- * ※ This is an alias for `Math.LOG2E`.
- */
- LOG2E: LOG2ℇ,
-
- /**
- * sqrt(½).
- *
- * ※ This is an alias for `Math.SQRT1_2`.
- */
- SQRT1_2: RECIPROCAL_SQRT2,
-
- /**
- * sqrt(2).
- *
- * ※ This is an alias for `Math.SQRT2`.
- */
- SQRT2,
-
- /**
- * The mathematical constant π.
- *
- * ※ This is an alias for `Math.PI`.
- */
- PI: Π,
-
- /**
- * The Euler number.
- *
- * ※ This is an alias for `Math.E`.
- */
- E: ℇ,
-} = Math;
-
-export const {
- /**
- * The largest number value less than infinity.
- *
- * ※ This is an alias for `Number.MAX_VALUE`.
- */
- MAX_VALUE: MAXIMUM_NUMBER,
-
- /**
- * 2**53 - 1.
- *
- * ※ This is an alias for `Number.MAX_SAFE_INTEGER`.
- */
- MAX_SAFE_INTEGER: MAXIMUM_SAFE_INTEGRAL_NUMBER,
-
- /**
- * The smallest number value greater than negative infinity.
- *
- * ※ This is an alias for `Number.MIN_VALUE`.
- */
- MIN_VALUE: MINIMUM_NUMBER,
-
- /**
- * -(2**53 - 1).
- *
- * ※ This is an alias for `Number.MIN_SAFE_INTEGER`.
- */
- MIN_SAFE_INTEGER: MINIMUM_SAFE_INTEGRAL_NUMBER,
-
- /**
- * Negative infinity.
- *
- * ※ This is an alias for `Number.NEGATIVE_INFINITY`.
- */
+import {
+ NAN,
NEGATIVE_INFINITY,
-
- /**
- * Nan.
- *
- * ※ This is an alias for `Number.NaN`.
- */
- NaN: NAN,
-
- /**
- * Positive infinity.
- *
- * ※ This is an alias for `Number.POSITIVE_INFINITY`.
- */
POSITIVE_INFINITY,
-
- /**
- * The difference between 1 and the smallest number greater than 1.
- *
- * ※ This is an alias for `Number.EPSILON`.
- */
- EPSILON: Ε,
-} = Number;
-
-/** Negative zero. */
-export const NEGATIVE_ZERO = -0;
-
-/** Positive zero. */
-export const POSITIVE_ZERO = 0;
+ sameValue,
+ toPrimitive,
+} from "./value.js";
/**
* Returns the magnitude (absolute value) of the provided value.
isNan,
isSafeIntegralNumber,
ln,
- LN10,
ln1p,
- LN2,
log10,
- LOG10ℇ,
log2,
- LOG2ℇ,
max,
- MAXIMUM_NUMBER,
- MAXIMUM_SAFE_INTEGRAL_NUMBER,
min,
- MINIMUM_NUMBER,
- MINIMUM_SAFE_INTEGRAL_NUMBER,
- NAN,
- NEGATIVE_INFINITY,
- NEGATIVE_ZERO,
- POSITIVE_INFINITY,
- POSITIVE_ZERO,
rand,
- RECIPROCAL_SQRT2,
round,
sgn,
sin,
sinh,
sqrt,
- SQRT2,
tan,
tanh,
toBigInt,
toSignedIntegralNumeric,
toUnsignedIntegralNumeric,
trunc,
- Ε,
- Π,
- ℇ,
} from "./numeric.js";
-describe("LN10", () => {
- it("[[Get]] is ln(10)", () => {
- assertStrictEquals(LN10, Math.LN10);
- });
-});
-
-describe("LN2", () => {
- it("[[Get]] is ln(2)", () => {
- assertStrictEquals(LN2, Math.LN2);
- });
-});
-
-describe("LOG10ℇ", () => {
- it("[[Get]] is log10(ℇ)", () => {
- assertStrictEquals(LOG10ℇ, Math.LOG10E);
- });
-});
-
-describe("LOG2ℇ", () => {
- it("[[Get]] is log2(ℇ)", () => {
- assertStrictEquals(LOG2ℇ, Math.LOG2E);
- });
-});
-
-describe("MAXIMUM_NUMBER", () => {
- it("[[Get]] is the maximum number", () => {
- assertStrictEquals(MAXIMUM_NUMBER, Number.MAX_VALUE);
- });
-});
-
-describe("MAXIMUM_SAFE_INTEGRAL_NUMBER", () => {
- it("[[Get]] is the maximum safe integral number", () => {
- assertStrictEquals(
- MAXIMUM_SAFE_INTEGRAL_NUMBER,
- Number.MAX_SAFE_INTEGER,
- );
- });
-});
-
-describe("MINIMUM_NUMBER", () => {
- it("[[Get]] is the minimum number", () => {
- assertStrictEquals(MINIMUM_NUMBER, Number.MIN_VALUE);
- });
-});
-
-describe("MINIMUM_SAFE_INTEGRAL_NUMBER", () => {
- it("[[Get]] is the minimum safe integral number", () => {
- assertStrictEquals(
- MINIMUM_SAFE_INTEGRAL_NUMBER,
- Number.MIN_SAFE_INTEGER,
- );
- });
-});
-
-describe("NAN", () => {
- it("[[Get]] is nan", () => {
- assertStrictEquals(NAN, NaN);
- });
-});
-
-describe("NEGATIVE_INFINITY", () => {
- it("[[Get]] is negative infinity", () => {
- assertStrictEquals(NEGATIVE_INFINITY, -Infinity);
- });
-});
-
-describe("NEGATIVE_ZERO", () => {
- it("[[Get]] is negative zero", () => {
- assertStrictEquals(NEGATIVE_ZERO, -0);
- });
-});
-
-describe("POSITIVE_INFINITY", () => {
- it("[[Get]] is negative infinity", () => {
- assertStrictEquals(POSITIVE_INFINITY, Infinity);
- });
-});
-
-describe("POSITIVE_ZERO", () => {
- it("[[Get]] is positive zero", () => {
- assertStrictEquals(POSITIVE_ZERO, 0);
- });
-});
-
-describe("RECIPROCAL_SQRT2", () => {
- it("[[Get]] is sqrt(½)", () => {
- assertStrictEquals(RECIPROCAL_SQRT2, Math.SQRT1_2);
- });
-});
-
-describe("SQRT2", () => {
- it("[[Get]] is sqrt(2)", () => {
- assertStrictEquals(SQRT2, Math.SQRT2);
- });
-});
-
-describe("Ε", () => {
- it("[[Get]] is ε", () => {
- assertStrictEquals(Ε, Number.EPSILON);
- });
-});
-
-describe("Π", () => {
- it("[[Get]] is π", () => {
- assertStrictEquals(Π, Math.PI);
- });
-});
-
-describe("ℇ", () => {
- it("[[Get]] is ℇ", () => {
- assertStrictEquals(ℇ, Math.E);
- });
-});
-
describe("abs", () => {
it("[[Call]] returns the absolute value", () => {
assertStrictEquals(abs(-1), 1);
unscopables: UNSCOPABLES,
} = Symbol;
+export const {
+ /**
+ * ln(10).
+ *
+ * ※ This is an alias for `Math.LN10`.
+ */
+ LN10,
+
+ /**
+ * ln(2).
+ *
+ * ※ This is an alias for `Math.LN2`.
+ */
+ LN2,
+
+ /**
+ * log10(ℇ).
+ *
+ * ※ This is an alias for `Math.LOG10E`.
+ */
+ LOG10E: LOG10ℇ,
+
+ /**
+ * log2(ℇ).
+ *
+ * ※ This is an alias for `Math.LOG2E`.
+ */
+ LOG2E: LOG2ℇ,
+
+ /**
+ * sqrt(½).
+ *
+ * ※ This is an alias for `Math.SQRT1_2`.
+ */
+ SQRT1_2: RECIPROCAL_SQRT2,
+
+ /**
+ * sqrt(2).
+ *
+ * ※ This is an alias for `Math.SQRT2`.
+ */
+ SQRT2,
+
+ /**
+ * The mathematical constant π.
+ *
+ * ※ This is an alias for `Math.PI`.
+ */
+ PI: Π,
+
+ /**
+ * The Euler number.
+ *
+ * ※ This is an alias for `Math.E`.
+ */
+ E: ℇ,
+} = Math;
+
+export const {
+ /**
+ * The largest number value less than infinity.
+ *
+ * ※ This is an alias for `Number.MAX_VALUE`.
+ */
+ MAX_VALUE: MAXIMUM_NUMBER,
+
+ /**
+ * 2**53 - 1.
+ *
+ * ※ This is an alias for `Number.MAX_SAFE_INTEGER`.
+ */
+ MAX_SAFE_INTEGER: MAXIMUM_SAFE_INTEGRAL_NUMBER,
+
+ /**
+ * The smallest number value greater than negative infinity.
+ *
+ * ※ This is an alias for `Number.MIN_VALUE`.
+ */
+ MIN_VALUE: MINIMUM_NUMBER,
+
+ /**
+ * -(2**53 - 1).
+ *
+ * ※ This is an alias for `Number.MIN_SAFE_INTEGER`.
+ */
+ MIN_SAFE_INTEGER: MINIMUM_SAFE_INTEGRAL_NUMBER,
+
+ /**
+ * Negative infinity.
+ *
+ * ※ This is an alias for `Number.NEGATIVE_INFINITY`.
+ */
+ NEGATIVE_INFINITY,
+
+ /**
+ * Nan.
+ *
+ * ※ This is an alias for `Number.NaN`.
+ */
+ NaN: NAN,
+
+ /**
+ * Positive infinity.
+ *
+ * ※ This is an alias for `Number.POSITIVE_INFINITY`.
+ */
+ POSITIVE_INFINITY,
+
+ /**
+ * The difference between 1 and the smallest number greater than 1.
+ *
+ * ※ This is an alias for `Number.EPSILON`.
+ */
+ EPSILON: Ε,
+} = Number;
+
+/** Negative zero. */
+export const NEGATIVE_ZERO = -0;
+
/** The null primitive. */
export const NULL = null;
+/** Positive zero. */
+export const POSITIVE_ZERO = 0;
+
/** The undefined primitive. */
export const UNDEFINED = undefined;
toLength,
} = (() => {
const { floor, max, min } = Math;
- const {
- MAX_SAFE_INTEGER: MAXIMUM_SAFE_INTEGRAL_NUMBER,
- isNaN: isNan,
- } = Number;
+ const { isNaN: isNan } = Number;
const { is } = Object;
return {
sameValue: (a, b) => is(a, b),
HAS_INSTANCE,
IS_CONCAT_SPREADABLE,
ITERATOR,
+ LN10,
+ LN2,
+ LOG10ℇ,
+ LOG2ℇ,
MATCH,
MATCH_ALL,
+ MAXIMUM_NUMBER,
+ MAXIMUM_SAFE_INTEGRAL_NUMBER,
+ MINIMUM_NUMBER,
+ MINIMUM_SAFE_INTEGRAL_NUMBER,
+ NAN,
+ NEGATIVE_INFINITY,
+ NEGATIVE_ZERO,
NULL,
ordinaryToPrimitive,
+ POSITIVE_INFINITY,
+ POSITIVE_ZERO,
+ RECIPROCAL_SQRT2,
REPLACE,
sameValue,
sameValueZero,
SPECIES,
SPLIT,
+ SQRT2,
TO_PRIMITIVE,
TO_STRING_TAG,
toIndex,
type,
UNDEFINED,
UNSCOPABLES,
+ Ε,
+ Π,
+ ℇ,
} from "./value.js";
describe("ASYNC_ITERATOR", () => {
});
});
+describe("LN10", () => {
+ it("[[Get]] is ln(10)", () => {
+ assertStrictEquals(LN10, Math.LN10);
+ });
+});
+
+describe("LN2", () => {
+ it("[[Get]] is ln(2)", () => {
+ assertStrictEquals(LN2, Math.LN2);
+ });
+});
+
+describe("LOG10ℇ", () => {
+ it("[[Get]] is log10(ℇ)", () => {
+ assertStrictEquals(LOG10ℇ, Math.LOG10E);
+ });
+});
+
+describe("LOG2ℇ", () => {
+ it("[[Get]] is log2(ℇ)", () => {
+ assertStrictEquals(LOG2ℇ, Math.LOG2E);
+ });
+});
+
describe("MATCH", () => {
it("[[Get]] is @@match", () => {
assertStrictEquals(MATCH, Symbol.match);
});
});
+describe("MAXIMUM_NUMBER", () => {
+ it("[[Get]] is the maximum number", () => {
+ assertStrictEquals(MAXIMUM_NUMBER, Number.MAX_VALUE);
+ });
+});
+
+describe("MAXIMUM_SAFE_INTEGRAL_NUMBER", () => {
+ it("[[Get]] is the maximum safe integral number", () => {
+ assertStrictEquals(
+ MAXIMUM_SAFE_INTEGRAL_NUMBER,
+ Number.MAX_SAFE_INTEGER,
+ );
+ });
+});
+
+describe("MINIMUM_NUMBER", () => {
+ it("[[Get]] is the minimum number", () => {
+ assertStrictEquals(MINIMUM_NUMBER, Number.MIN_VALUE);
+ });
+});
+
+describe("MINIMUM_SAFE_INTEGRAL_NUMBER", () => {
+ it("[[Get]] is the minimum safe integral number", () => {
+ assertStrictEquals(
+ MINIMUM_SAFE_INTEGRAL_NUMBER,
+ Number.MIN_SAFE_INTEGER,
+ );
+ });
+});
+
+describe("NAN", () => {
+ it("[[Get]] is nan", () => {
+ assertStrictEquals(NAN, NaN);
+ });
+});
+
+describe("NEGATIVE_INFINITY", () => {
+ it("[[Get]] is negative infinity", () => {
+ assertStrictEquals(NEGATIVE_INFINITY, -Infinity);
+ });
+});
+
+describe("NEGATIVE_ZERO", () => {
+ it("[[Get]] is negative zero", () => {
+ assertStrictEquals(NEGATIVE_ZERO, -0);
+ });
+});
+
describe("NULL", () => {
it("[[Get]] is null", () => {
assertStrictEquals(NULL, null);
});
});
+describe("POSITIVE_INFINITY", () => {
+ it("[[Get]] is negative infinity", () => {
+ assertStrictEquals(POSITIVE_INFINITY, Infinity);
+ });
+});
+
+describe("POSITIVE_ZERO", () => {
+ it("[[Get]] is positive zero", () => {
+ assertStrictEquals(POSITIVE_ZERO, 0);
+ });
+});
+
+describe("RECIPROCAL_SQRT2", () => {
+ it("[[Get]] is sqrt(½)", () => {
+ assertStrictEquals(RECIPROCAL_SQRT2, Math.SQRT1_2);
+ });
+});
+
describe("REPLACE", () => {
it("[[Get]] is @@replace", () => {
assertStrictEquals(REPLACE, Symbol.replace);
});
});
+describe("SQRT2", () => {
+ it("[[Get]] is sqrt(2)", () => {
+ assertStrictEquals(SQRT2, Math.SQRT2);
+ });
+});
+
describe("TO_PRIMITIVE", () => {
it("[[Get]] is @@toPrimitive", () => {
assertStrictEquals(TO_PRIMITIVE, Symbol.toPrimitive);
});
});
+describe("Ε", () => {
+ it("[[Get]] is ε", () => {
+ assertStrictEquals(Ε, Number.EPSILON);
+ });
+});
+
+describe("Π", () => {
+ it("[[Get]] is π", () => {
+ assertStrictEquals(Π, Math.PI);
+ });
+});
+
+describe("ℇ", () => {
+ it("[[Get]] is ℇ", () => {
+ assertStrictEquals(ℇ, Math.E);
+ });
+});
+
describe("ordinaryToPrimitive", () => {
it("[[Call]] prefers `valueOf` by default", () => {
const obj = {