@adviser/cement - v0.0.0
    Preparing search index...

    Type Alias EnvFactory

    EnvFactory: (opts?: Partial<EnvFactoryOpts>) => Env

    Creates a platform-appropriate environment variable interface.

    Automatically detects the runtime environment (Node.js, Deno, browser, Cloudflare Workers) and returns an Env instance with platform-specific implementations. Supports preset values, change notifications, and type-safe multi-key retrieval.

    Type Declaration

      • (opts?: Partial<EnvFactoryOpts>): Env
      • Parameters

        • Optionalopts: Partial<EnvFactoryOpts>

          Optional configuration:

          • symbol: Key for browser environment storage (default: "CP_ENV")
          • presetEnv: Map of preset environment variables
          • testPatchImportMetaEnv: Test values to patch into import.meta.env
          • id: Identifier for caching/reinitialization

        Returns Env

        Env instance for the detected platform

    Error if no compatible environment is detected

    const env = envFactory();

    // Get single value
    const apiKey = env.get('API_KEY');

    // Get multiple values with Result
    const config = env.gets('DB_HOST', 'DB_PORT', 'DB_NAME');
    if (config.isOk()) {
    const { DB_HOST, DB_PORT, DB_NAME } = config.unwrap();
    }

    // Listen for changes
    env.onSet((key, value) => {
    console.log(`${key} changed to ${value}`);
    }, 'API_KEY'); // Optional: filter by specific keys