import {codeWarningOnce} from '@befe/brick-utils'

export function createInitOpts<T>(moduleName: string) {
    let innerInitOpts: T

    return {
        get inited() {
            return !!innerInitOpts
        },

        init(initOpts: T) {
            innerInitOpts = initOpts
        },

        get() {
            codeWarningOnce(
                !!innerInitOpts,
                `${moduleName} 需要 init() 一下`
            )

            return innerInitOpts
        },
    }
}
