npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

offline-city-search

v2.0.2

Published

Offline, zero-latency city search with latitude, longitude, and IANA timezone. No API keys. No network. Just fast.

Readme

offline-city-search

Offline, zero-latency city search for Node.js using an embedded SQLite database.

npm version license

What It Is

offline-city-search ships with a prebuilt cities.db (GeoNames-based SQLite database) and exposes synchronous lookup APIs:

  • prefix city search (searchCity)
  • lookup by city id (getCityById)
  • nearest-city by coordinates (getNearestCity)

Runtime Support

  • Node.js only (uses built-in node:sqlite)
  • Requires Node.js >= 22.5.0
  • Tested on Node.js 22 and 25
  • Not intended for direct browser/frontend bundling
  • Typical usage: call from your backend API and return results to frontend clients

Installation

npm install offline-city-search

Package note:

  • Includes a prebuilt SQLite file (cities.db)
  • Current tarball size is around 13-14MB (compressed)

Compatibility Notes (Important)

offline-city-search uses the built-in node:sqlite module (no native npm addon required). This avoids most install-time native binary issues.

Recommended for most users:

  • Use Node.js LTS (22)
  • Keep local and CI Node versions consistent
# with nvm
nvm install 22
nvm use 22
rm -rf node_modules package-lock.json
npm install

If your project must run on a newer Node major:

  • Validate behavior in CI before release
  • Keep this package in server-only runtime paths

Usage

import { searchCity, getCityById, getNearestCity } from "offline-city-search";

const top = searchCity("mum", { limit: 5, countryCode: "IN" });
const city = getCityById(1275339); // Mumbai
const near = getNearestCity(19.07283, 72.88261);

API

searchCity(query, options?)

  • query: string prefix text (case-insensitive behavior via normalized ASCII-lower field)
  • options.limit?: number max rows, default 5
  • options.countryCode?: string ISO alpha-2 code, e.g. "IN"

Returns: City[]

getCityById(id)

  • id: number GeoNames id

Returns: City | null

getNearestCity(lat, lng)

  • lat: number
  • lng: number

Returns: City | null

City

interface City {
  id: number;
  name: string;
  asciiName: string;
  state: string;
  countryCode: string;
  lat: number;
  lng: number;
  timezone: string;
  population: number;
}

Data Source

GeoNames cities1000 + admin1CodesASCII (state/province mapping):

  • https://www.geonames.org/
  • License: CC BY 4.0

Rebuilding Database (Maintainers)

npm install
npm run build:db
npm run build

The build pipeline:

  • downloads GeoNames files
  • inserts rows in batches
  • creates indexes
  • runs ANALYZE, integrity check, and VACUUM

Publish Checklist

See PUBLISHING.md.

License

MIT