'use strict'; /** Support some unreasonable feature * @module exampleUtilityTwo */ import * as SomeUtil from '../../utility/some-util'; // NOTE: Unit tests use the exported class, while Site.js uses the exported instance // // Definitions // /** Obviously, the best thing * @type {string} */ const bestThing = 'bliss'; // // Exports // /** An object that knows how to interpret the hostname of the current site. * * We serve our website on multiple domains, and sometimes we do things * differently based on which domain. */ export class ExampleUtilityTwo { /** List of secret things * @type {array.<string>} * @private */ _things = [ '213a99', '11f860', '114g89' ]; /** The best of the things * * This class may not recognize this best thing, but it will. * @type {string} */ bestThing; /** Store and recognize the best thing * @param {string} bestThing - The best thing */ constructor(bestThing) { const isKnownBestThing = this.isKnownThing(bestThing); this.bestThing = bestThing; if (!isKnownBestThing) { this._things.push(this.bestThing); } } /** Whether a thing is recognized * @param {string} thing - A thing that may be recognized * @return {boolean} */ isKnownThing(thing) { return this._things.includes(thing) && SomeUtil.isThingKnowledgeExpected; } } /** Instance of the class of this module * * > Notice that because `ExampleUtilityTwo` is exported, * it is reerenced with a dot `.`, not a tilde `~` * @type {module:exampleUtilityTwo.ExampleUtilityTwo} */ export const exampleUtilityTwo = new ExampleUtilityTwo(bestThing);