class NanoPowConfigConstructor implements NanoPowOptions {
static #isInternal: boolean = false
+ static get isInternal (): boolean { return this.#isInternal }
api: ApiSupportedTypes
debug: boolean
difficulty: bigint
}
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> {
this.#isInternal = true
const config = new this(api, debug, difficulty, effort)
+ this.#isInternal = false
return config
}