]> Lady’s Gitweb - Pisces/blob - symbol.js
Minor refactors to numeric.js
[Pisces] / symbol.js
1 // SPDX-FileCopyrightText: 2023, 2025 Lady <https://www.ladys.computer/about/#lady>
2 // SPDX-License-Identifier: MPL-2.0
3 /**
4 * ⁌ ♓🧩 Piscēs ∷ symbol.js
5 *
6 * Copyright © 2023, 2025 Lady [@ Ladys Computer].
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
11 */
12
13 import { createCallableFunction } from "./function.js";
14
15 const PISCĒS = "♓🧩 Piscēs";
16
17 /**
18 * Returns the description for the provided symbol.
19 *
20 * ※ This is effectively an alias for the `Symbol::description´
21 * getter.
22 *
23 * ☡ This function throws if the provided argument is not a symbol.
24 */
25 export const getSymbolDescription = createCallableFunction(
26 Object.getOwnPropertyDescriptor(Symbol.prototype, "description").get,
27 { name: "getSymbolDescription" },
28 );
29
30 /**
31 * Returns a string representation of the provided symbol.
32 *
33 * ※ Use `getSymbolDescription´ instead if you just want the text
34 * description of a symbol.
35 *
36 * ※ This is effectively an alias for the `Symbol::toString´.
37 *
38 * ☡ This function throws if the provided argument is not a symbol.
39 */
40 export const symbolToString = createCallableFunction(
41 Symbol.prototype.toString,
42 { name: "symbolToString" },
43 );
44
45 /**
46 * Returns the value of the provided symbol.
47 *
48 * ※ This is effectively an alias for the `Symbol::valueOf´.
49 *
50 * ☡ This function throws if the provided argument is not a symbol and
51 * does not have a `[[SymbolData]]´ slot.
52 */
53 export const symbolValue = createCallableFunction(
54 Symbol.prototype.valueOf,
55 { name: "symbolValue" },
56 );
This page took 0.483528 seconds and 5 git commands to generate.