JS Utils Kit
    Preparing search index...

    Variable hasCommonJSFilenameConst

    hasCommonJSFilename: boolean = ...

    Determines whether the current runtime provides the CommonJS __filename variable.

    • In CommonJS environments, Node.js injects a module-scoped __filename variable representing the absolute path of the current module file.
    • In pure ESM environments, __filename does not exist.
    • This helper allows environment-aware branching while remaining testable (e.g., via mocking in unit tests).

    true if __filename is available in the current runtime; otherwise false.

    if (hasCommonJSFilename) {
    console.log("Running in CommonJS environment");
    } else {
    console.log("Running in ESM environment");