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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@darkwolf/geohash

v1.0.6

Published

Geohash

Readme

Geohash

Install

npm i --save @darkwolf/geohash

Usage

// ECMAScript
import Geohash from '@darkwolf/geohash'
// CommonJS
const Geohash = require('@darkwolf/geohash')

const location = {
  latitude: 64.0123456789,
  longitude: 64.0123456789
}

// Geohash Encoding
const encoded = Geohash.encode(location.latitude, location.longitude) // => 'v7ms0th6gy'
const decoded = Geohash.decode(encoded) // =>
// {
//   latitude: 64.01234775781631,
//   longitude: 64.01235044002533
// }
const decodedBoundingBox = Geohash.decodeBoundingBox(encoded) // =>
// [
//   64.0123450756073, // minLat
//   64.0123450756073, // minLon
//   64.01235044002533, // maxLat
//   64.01235580444336 // maxLon
// ]

const encodedWithMaxPrecision = Geohash.encode(location.latitude, location.longitude, 22) // => 'v7ms0th6gy07w7hthsg7my'
const decodedWithMaxPrecision = Geohash.decode(encodedWithMaxPrecision) // =>
// {
//   latitude: 64.0123456789,
//   longitude: 64.0123456789
// }
const decodedBoundingBoxWithMaxPrecision = Geohash.decodeBoundingBox(encodedWithMaxPrecision) // =>
// [
//   64.01234567889999,
//   64.01234567889999,
//   64.0123456789,
//   64.0123456789
// ]

const neighbor = Geohash.getNeighbor(encoded, 'north') // => 'v7ms0th6gz'
const neighbors = Geohash.getNeighbors(encoded) // =>
// {
//   north: 'v7ms0th6gz',
//   northeast: 'v7ms0th6up',
//   east: 'v7ms0th6un',
//   southeast: 'v7ms0th6uj',
//   south: 'v7ms0th6gv',
//   southwest: 'v7ms0th6gt',
//   west: 'v7ms0th6gw',
//   northwest: 'v7ms0th6gx'
// }

// Geoint Encoding
const encodedInt = Geohash.encodeInt(location.latitude, location.longitude) // => 3833413037484024
const decodedInt = Geohash.decodeInt(encodedInt) // =>
// {
//   latitude: 64.01234641671181,
//   longitude: 64.01234775781631
// }
const decodedBoundingBoxInt = Geohash.decodeBoundingBoxInt(encodedInt) // =>
// [
//   64.0123450756073,
//   64.0123450756073,
//   64.01234775781631,
//   64.01235044002533
// ]

const neighborInt = Geohash.getNeighborInt(encodedInt, 'north') // => 3833413037484025
const neighborsInt = Geohash.getNeighborsInt(encodedInt) // =>
// {
//   north: 3833413037484025,
//   northeast: 3833413037484027,
//   east: 3833413037484026,
//   southeast: 3833413037484015,
//   south: 3833413037484013,
//   southwest: 3833413037484007,
//   west: 3833413037484018,
//   northwest: 3833413037484019
// }

// Geobigint Encoding
const encodedBigInt = Geohash.encodeBigInt(location.latitude, location.longitude) // => 15701659801534562430n
const decodedBigInt = Geohash.decodeBigInt(encodedBigInt) // =>
// {
//   latitude: 64.01234568329528,
//   longitude: 64.01234570425004
// }
const decodedBoundingBoxBigInt = Geohash.decodeBoundingBoxBigInt(encodedBigInt) // =>
// [
//   64.01234566234052,
//   64.01234566234052,
//   64.01234570425004,
//   64.01234574615955
// ]

const encodedBigIntWithMaxBits = Geohash.encodeBigInt(location.latitude, location.longitude, 110) // => 1104906081738896117776798162853502n
const decodedBigIntWithMaxBits = Geohash.decodeBigInt(encodedBigIntWithMaxBits, 110) // =>
// {
//   latitude: 64.0123456789,
//   longitude: 64.0123456789
// }
const decodedBoundingBoxBigIntWithMaxBits = Geohash.decodeBoundingBoxBigInt(encodedBigIntWithMaxBits, 110) // =>
// [
//   64.01234567889999,
//   64.01234567889999,
//   64.0123456789,
//   64.0123456789
// ]

const neighborBigInt = Geohash.getNeighborBigInt(encodedBigInt, 'north') // => 15701659801534562431n
const neighborsBigInt = Geohash.getNeighborsBigInt(encodedBigInt) // =>
// {
//   north: 15701659801534562431n,
//   northeast: 15701659801534562517n,
//   east: 15701659801534562516n,
//   southeast: 15701659801534562513n,
//   south: 15701659801534562427n,
//   southwest: 15701659801534562425n,
//   west: 15701659801534562428n,
//   northwest: 15701659801534562429n
// }

API Documentation

Contact Me

GitHub: @PavelWolfDark

Telegram: @PavelWolfDark

Email: [email protected]