]> Lady’s Gitweb - Etiquette/blobdiff - memory.js
Apply some reformatting and make Reuse‐compliant
[Etiquette] / memory.js
index 252418b3f85e4e5c2493b8263399e0acb900267f..f4a861b1249ca82ad2e8bf5c82c3c9ad27ad31c0 100644 (file)
--- a/memory.js
+++ b/memory.js
@@ -1,14 +1,19 @@
-// 📧🏷️ Étiquette ∷ memory.js
-// ====================================================================
-//
-// Copyright © 2023 Lady [@ Lady’s Computer].
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// 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/>.
+// SPDX-FileCopyrightText: 2023, 2025 Lady <https://www.ladys.computer/about/#lady>
+// SPDX-License-Identifier: MPL-2.0
+/**
+ * ⁌ 📧🏷️ Étiquette ∷ memory.js
+ *
+ * Copyright © 2023, 2025 Lady [@ Ladys Computer].
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 { wrmgBase32Binary, wrmgBase32String } from "./deps.js";
 
+const ÉTIQUETTE = "📧🏷️ Étiquette";
+
 /**
  * A symbol which is used internally to identify the constructor
  * associated with a stored object.
@@ -23,7 +28,7 @@ const constructorSymbol = Symbol("constructor");
  * If an argument is provided, it is used as the underlying numeric
  * value for the identifier.
  *
- * The return value is a `String` *object* with a `.value` own property
+ * The return value is a `String´ ⹐object⹑ with a `.value´ own property
  * giving the underlying numeric value for the string.
  *
  * ※ This function is not exposed.
@@ -83,7 +88,7 @@ const normalizeID = ($) => {
     if (byteLength != 4) {
       // ☡ The identifier was of unexpected size.
       throw new RangeError(
-        `Expected id to fit within 4 bytes, but got ${byteLength}.`,
+        `${ÉTIQUETTE}: Expected id to fit within 4 bytes, but got ${byteLength}.`,
       );
     } else {
       // The identifier was correctly‐sized.
@@ -94,14 +99,16 @@ const normalizeID = ($) => {
         //
         // ※ This should be impossible and indicates something went
         // very wrong in base32 decoding.
-        throw new RangeError("Unexpected values in lower two bits");
+        throw new RangeError(
+          `${ÉTIQUETTE}: Unexpected values in lower two bits`,
+        );
       } else {
         // The final two bits are zero as expected.
         const number = value >>> 2;
         if (checksum != number % 37) {
           // ☡ The checksum does not match the number.
           throw new RangeError(
-            `Invalid checksum for id: ${identifier} (${number})`,
+            `${ÉTIQUETTE}: Invalid checksum for id: ${identifier} (${number})`,
           );
         } else {
           // The checksum matches. Mint a new identifier with the same
@@ -117,7 +124,7 @@ const normalizeID = ($) => {
  * A symbol which is used to identify the method for constructing a new
  * instance of a constructor based on stored data.
  *
- * ※ This value is exposed as `Storage.toInstance`.
+ * ※ This value is exposed as `Storage.toInstance´.
  */
 const toInstanceSymbol = Symbol("Storage.toInstance");
 
@@ -126,7 +133,7 @@ const toInstanceSymbol = Symbol("Storage.toInstance");
  * instance into an object of enumerable own properties suitable for
  * persistence.
  *
- * ※ This value is exposed as `Storage.toObject`.
+ * ※ This value is exposed as `Storage.toObject´.
  */
 const toObjectSymbol = Symbol("Storage.toObject");
 
@@ -136,7 +143,7 @@ const toObjectSymbol = Symbol("Storage.toObject");
  */
 export class Storage {
   static {
-    // Define `Storage.toInstance` and `Storage.toObject` as
+    // Define `Storage.toInstance´ and `Storage.toObject´ as
     // nonconfigurable, non·enumerable, read·only properties with the
     // appropriate values.
     Object.defineProperties(this, {
@@ -156,15 +163,15 @@ export class Storage {
   }
 
   /**
-   * A `Set` of deleted identifiers, to ensure they are not
+   * A `Set´ of deleted identifiers, to ensure they are not
    * re·assigned.
    *
-   * The identifier `000-0000` is deleted from the start and can only
+   * The identifier `000-0000´ is deleted from the start and can only
    * be manually set.
    */
   #deleted = new Set([`${mintID(0)}`]);
 
-  /** The `Map` used to actually store the data internally. */
+  /** The `Map´ used to actually store the data internally. */
   #store = new Map();
 
   /**
@@ -180,7 +187,7 @@ export class Storage {
       // ☡ There is no method on the constructor for generating an
       // instance.
       throw new TypeError(
-        "Constructor must implement Storage.toInstance for object to be retrieved.",
+        `${ÉTIQUETTE}: Constructor must implement Storage.toInstance for object to be retrieved.`,
       );
     } else {
       // Generate an instance and return it.
@@ -204,7 +211,7 @@ export class Storage {
       // The provided value does not have a method for generating an
       // object to store.
       throw new TypeError(
-        "Object must implement Storage.toObject to be stored.",
+        `${ÉTIQUETTE}: Object must implement Storage.toObject to be stored.`,
       );
     } else {
       // The provided value has a method for generating a storage
@@ -289,9 +296,9 @@ export class Storage {
    * constructed from data in storage.
    *
    * The callback function will be called with the constructed
-   * instance, its identifier, and this `Storage` instance.
+   * instance, its identifier, and this `Storage´ instance.
    *
-   * If a second argument is provided, it will be used as the `this`
+   * If a second argument is provided, it will be used as the `this´
    * value.
    */
   forEach(callback, thisArg = undefined) {
@@ -304,7 +311,7 @@ export class Storage {
 
   /**
    * Returns an instance constructed from the data stored at the
-   * provided identifier, or `null` if the identifier has no data.
+   * provided identifier, or `null´ if the identifier has no data.
    */
   get(id) {
     const store = this.#store;
@@ -336,7 +343,7 @@ export class Storage {
 
   /**
    * Sets the data for the provided identifier to be that generated
-   * from the provided instance, then returns this `Storage` object.
+   * from the provided instance, then returns this `Storage´ object.
    */
   set(id, instance) {
     this.#persist(instance, normalizeID(id));
@@ -347,7 +354,7 @@ export class Storage {
    * Returns the number of identifiers with data in storage.
    *
    * ☡ This number may be smaller than the actual number of used
-   * identifiers, as deleted identifiers are *not* freed up for re·use.
+   * identifiers, as deleted identifiers are ⹐not⹑ freed up for re·use.
    */
   get size() {
     return this.#store.size;
This page took 0.116727 seconds and 4 git commands to generate.