From: Chris Duncan Date: Sun, 21 Sep 2025 22:37:02 +0000 (-0700) Subject: Eliminate self-reference to allow esbuild to generate anonymous class. X-Git-Tag: v5.1.7~1 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=2a29e3d87c59a162fc239b9a7fa86bddbda27dea;p=nano-pow.git Eliminate self-reference to allow esbuild to generate anonymous class. --- diff --git a/src/lib/config/index.ts b/src/lib/config/index.ts index 482b6dc..113c32c 100644 --- a/src/lib/config/index.ts +++ b/src/lib/config/index.ts @@ -8,6 +8,7 @@ type ApiSupportedTypes = keyof typeof ApiSupport class NanoPowConfigConstructor implements NanoPowOptions { static #isInternal: boolean = false + static get isInternal (): boolean { return this.#isInternal } api: ApiSupportedTypes debug: boolean difficulty: bigint @@ -23,14 +24,13 @@ class NanoPowConfigConstructor implements NanoPowOptions { } constructor (api: ApiSupportedTypes, debug: boolean, difficulty: bigint, effort: number) { - if (!NanoPowConfigConstructor.#isInternal) { + if (!(this.constructor as typeof NanoPowConfigConstructor).isInternal) { throw new TypeError(`NanoPowConfig cannot be constructed with 'new'.`) } this.api = api this.debug = debug this.difficulty = difficulty this.effort = effort - NanoPowConfigConstructor.#isInternal = false } static async create (options: { api: unknown, debug: unknown, difficulty: unknown, effort: unknown } | unknown): Promise { @@ -43,6 +43,7 @@ class NanoPowConfigConstructor implements NanoPowOptions { this.#isInternal = true const config = new this(api, debug, difficulty, effort) + this.#isInternal = false return config }