• Pre-fetches databases from the mirror.

    Returns

    A Promise that resolves with your reader instance when the databases have been successfully downloaded and your reader initialized. Calling .close() on the reader will gracefully stop the background databases auto-updater, and run the reader's actual close() method if there is one, supporting arguments passthrough.

    Type Parameters

    Type Parameters

    • DbReaderInstance extends {}

      The type of a database reader instance. You can either supply it manually or let Typescript infer it from the readerInitializer param.

    Parameters

    • dbName: GeoIpDbName

      The database to open. You can find available databases in the GeoIpDbName enum or use string names directly in JS. Will be downloaded if it hasn't already been fetched (see downloadDbs to pre-fetch at an earlier time).

    • readerInitializer: ((path: string) => DbReaderInstance | Promise<DbReaderInstance>)

      A function that takes the absolute path to the downloaded .mmmdb database and returns a new DbReaderInstance. You need to supply it to this library so we can re-initialize your reader when the databases are auto-updated.

        • (path: string): DbReaderInstance | Promise<DbReaderInstance>
        • Parameters

          • path: string

          Returns DbReaderInstance | Promise<DbReaderInstance>

    • Optional downloadDirPath: string

      The path to the directory where the database should be stored. Defaults to ./node_modules/node-geolite2-redist/dbs. See downloadDbs for more information.

    Returns Promise<WrappedReader<DbReaderInstance>>

Generated using TypeDoc