fynjs API
    Preparing search index...

    Type Alias OptionalImportFunction<T>

    function to import a module with optional handling in case it's not found

    type OptionalImportFunction<T = any> = {
        has: (specifier: string) => boolean;
        log: LogFunction;
        resolve: (specifier: string, optsOrMsg?: OptsOrMessage) => any;
        (specifier: string, optsOrMsg?: OptsOrMessage): Promise<T>;
    }

    Type Parameters

    • T = any
    • Parameters

      • specifier: string

        the module specifier to import

      • OptionaloptsOrMsg: OptsOrMessage

        options, or message to log when the module is not found

      Returns Promise<T>

    Index
    has: (specifier: string) => boolean

    synchronously check whether the module is available, without evaluating it

    Type Declaration

      • (specifier: string): boolean
      • Parameters

        • specifier: string

          the module specifier to check

        Returns boolean

        true if the specifier resolves

    a resolve error that does not mean "not installed", such as an invalid package.json, so a broken install is never reported as absent

    function to log message, default to use console.log, you can replace this with another function.

    resolve: (specifier: string, optsOrMsg?: OptsOrMessage) => any

    synchronously resolve the module's URL, without evaluating it

    Type Declaration

      • (specifier: string, optsOrMsg?: OptsOrMessage): any
      • Parameters

        • specifier: string

          the module specifier to resolve

        • OptionaloptsOrMsg: OptsOrMessage

          options, or message to log when the module is not found

        Returns any

        the resolved URL, or the default / notFound result when not found