]> git.codecow.com Git - nano-pow.git/commitdiff
Eliminate self-reference to allow esbuild to generate anonymous class.
authorChris Duncan <chris@zoso.dev>
Sun, 21 Sep 2025 22:37:02 +0000 (15:37 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 21 Sep 2025 22:37:02 +0000 (15:37 -0700)
src/lib/config/index.ts

index 482b6dc5eb9a8f5587c64005daf5f9c20a45d318..113c32c0f65995a61046e060b72272af642ee2c8 100644 (file)
@@ -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<NanoPowConfigConstructor> {
@@ -43,6 +43,7 @@ class NanoPowConfigConstructor implements NanoPowOptions {
 
                this.#isInternal = true
                const config = new this(api, debug, difficulty, effort)
+               this.#isInternal = false
                return config
        }