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

sensor-mock

v0.6.0

Published

Mock browser sensor APIs (starting with Geolocation) with live data streamed from a sensor-sim server, no browser extension required.

Readme

sensor-mock

Mock browser sensor APIs — starting with Geolocation — with live data streamed from a running sensor-sim server simulation. It patches navigator.geolocation in place, so any code using the standard Geolocation API (getCurrentPosition, watchPosition) transparently receives mocked coordinates instead of the real device GPS.

Install

npm install sensor-mock
# or
pnpm add sensor-mock

Usage

import {enableSensorMock} from "sensor-mock";

const handle = enableSensorMock({
  url: "https://sensor-sim.h9e.de/s/<token>", // stream url (includes the auth token)
  urlStorageKey: "sensor-mock-url",           // optional: persist a url applied via the overlay
  overlay: true,                              // optional bottom-left status widget (default: true)
});

navigator.geolocation.watchPosition((position) => {
  console.log(position.coords.latitude, position.coords.longitude);
});

// later, to stop mocking and restore the real navigator.geolocation:
handle.disable();

Only one sensor-mock instance can be active at a time (navigator.geolocation is a single global object). Calling enableSensorMock again automatically tears down any previous instance first.

Options

| Option | Type | Required | Description | |-----------------|-----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | url | string | no | URL to stream the sensor updates from (includes a token for authentication). http(s):// is converted to ws(s):// internally and /ws is appended. If omitted or empty, mocking stays disabled until a url is applied via the overlay. | | urlStorageKey | string | no | localStorage key. If set, a url applied via the overlay is saved under this key, and on startup a saved non-empty url takes precedence over url. | | overlay | boolean | no | Show a small bottom-left overlay with connection status, current coordinates, and an enable/disable toggle. Defaults to true; can be toggled later via handle.setOverlayVisible. |

All options are optional, so enableSensorMock() can be called without arguments.

Handle API

enableSensorMock returns a handle:

  • disable() — restores the real navigator.geolocation and closes the connection.
  • setOverlayVisible(visible) — shows or hides the overlay widget.
  • status — current { enabled, connection, position } snapshot.
  • subscribe(callback) — subscribe to status changes; returns an unsubscribe function.

Overlay

When the overlay is enabled, a minimal, dependency-free widget is mounted in the bottom-left corner showing mock state, connection status, and current coordinates, with a button to toggle mocking on/off without losing the connection or removing the widget. A text input shows the current url (empty if none is set); enter a url and press Apply (or Enter) to enable mocking and reconnect to the server with it. If urlStorageKey is set, the applied url is saved to localStorage.

Notes

  • Zero runtime dependencies; ships as ESM + CJS with type declarations.
  • Uses the native WebSocket API, so it works in any browser without a bundler.