Represents a reader for MaxMind DB databases.

Type Parameters

Hierarchy

  • MmdbReader

Accessors

  • get fileName(): string
  • Gets the name of the database file which was opened, as passed to MmdbReader.open.

    Note: This property remains accessible after the reader has been closed.

    Returns string

  • get fileSize(): number
  • Gets the size of the database in bytes.

    Note: This property remains accessible after the reader has been closed.

    Returns number

  • get depth(): number
  • Gets the depth of the database search tree.

    Note: This property remains accessible after the reader has been closed.

    Returns number

  • get metadata(): MmdbMetadata
  • Gets the metadata for the database.

    Note: This property remains accessible after the reader has been closed.

    Returns MmdbMetadata

Methods

  • Opens a MaxMind DB database and returns a reader for it.

    Type Parameters

    Parameters

    Returns Promise<MmdbReader<E>>

    A promise that resolves with a new reader on success; or a promise that rejects with an MmdbError on failure.

  • Closes the reader and releases any associated resources.

    This method is called automatically when the reader is garbage collected, so it is not necessary to call it explicitly. However it is recommended to call it explicitly when you are done with the reader, so that resources are released promptly.

    It's safe to call this method multiple times, even if the reader has already been closed.

    Returns Promise<boolean>

    A promise that resolves with a boolean indicating whether the reader was closed (true) or was already closed (false). The promise will never reject.

  • Looks up an IP address in the database.

    Parameters

    • ip: string

      The IP address to look up.

    Returns Promise<MmdbLookupResult<E>>

    A promise that resolves to a MmdbLookupResult on success (whether or not the IP address was found); or a promise that rejects with GetAddrError if the IP address is invalid; or a promise that rejects with MmdbError if the lookup fails for any other reason.

Generated using TypeDoc