]> Lady’s Gitweb - Pisces/blobdiff - value.js
Add symbolToString and symbolValue to symbol.js
[Pisces] / value.js
index 782c857f934f6eaee9a107c940cfb22df2ea69ac..bda9180e4347e6cd74f0b36676fa82da208a2384 100644 (file)
--- a/value.js
+++ b/value.js
@@ -54,10 +54,10 @@ export const UNDEFINED = undefined;
 export const {
   /**
    * Returns the primitive value of the provided object per its
-   * `toString` and `valueOf` methods.
+   * `.toString` and `.valueOf` methods.
    *
-   * If the provided hint is "string", then `toString` takes
-   * precedence; otherwise, `valueOf` does.
+   * If the provided hint is "string", then `.toString` takes
+   * precedence; otherwise, `.valueOf` does.
    *
    * Throws an error if both of these methods are not callable or do
    * not return a primitive.
@@ -70,7 +70,7 @@ export const {
    *
    * The provided preferred type, if specified, should be "string",
    * "number", or "default". If the provided input has a
-   * `[Symbol.toPrimitive]` method, this function will throw rather
+   * `.[Symbol.toPrimitive]` method, this function will throw rather
    * than calling that method with a preferred type other than one of
    * the above.
    */
@@ -123,7 +123,7 @@ export const {
           if (typeof exoticToPrim !== "function") {
             // The method is not callable.
             throw new TypeError(
-              "Piscēs: `[Symbol.toPrimitive]` was neither nullish nor callable.",
+              "Piscēs: `.[Symbol.toPrimitive]` was neither nullish nor callable.",
             );
           } else {
             // The method is callable.
@@ -141,14 +141,14 @@ export const {
   };
 })();
 
-/**
- * Returns whether the provided values are the same value.
- *
- * ※ This differs from `===` in the cases of nan and zero.
- */
-export const sameValue = Object.is;
-
 export const {
+  /**
+   * Returns whether the provided values are the same value.
+   *
+   * ※ This differs from `===` in the cases of nan and zero.
+   */
+  sameValue,
+
   /**
    * Returns whether the provided values are either the same value or
    * both zero (either positive or negative).
@@ -158,7 +158,9 @@ export const {
   sameValueZero,
 } = (() => {
   const { isNaN: isNan } = Number;
+  const { is } = Object;
   return {
+    sameValue: (a, b) => is(a, b),
     sameValueZero: ($1, $2) => {
       const type1 = type($1);
       const type2 = type($2);
This page took 0.049193 seconds and 4 git commands to generate.