@ferrybig/cgeodata-reader
    Preparing search index...
    • Opens a .bin file from disk, reading only what each lookup needs, with Node's zlib as its inflater.

      The search and locate indexes next to it (searchIndexPathFor, locateIndexPathFor) are used automatically when they exist: each is opened on the first search() / locate() that can use it. One that exists but doesn't belong to this file (built from an older build of it, say) makes those calls reject with a CGeoDataIndexMismatchError naming it, rather than silently falling back to a slow scan; rebuild or delete it. options.searchIndex / options.locateIndex override the lookup next to the file.

      Parameters

      Returns Promise<CGeoDataReader>

      const reader = await openFile("data/world.bin");
      const { city } = await reader.query(52.37, 4.9);
      city?.internationalName; // "Amsterdam"
      await reader.close();