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

@nodesonar/core

v0.3.1

Published

nodesonar core library

Readme

@nodesonar/core

NPM Version NPM Downloads CI License Node Version

A TypeScript network scanning and monitoring toolkit for Node.js. Discover devices on your network, ping hosts, and poll devices at configurable intervals — all with a clean, typed API.


Features

  • 📡 Host Pinging — Ping any host or IP address and get structured results
  • 🔄 Device Polling — Poll one or more hosts at configurable intervals with live callbacks
  • 🔍 IP Range Scanning — Discover reachable devices across CIDR, dash, and wildcard ranges
  • 🧠 Flexible IP Range Parsing — Supports CIDR, dash ranges, full IP-to-IP ranges, and wildcards
  • 💪 Fully Typed — Written in TypeScript with declaration files included

Installation

npm install @nodesonar/core

Usage

Poller — Poll hosts at a configurable interval

import { Poller } from '@nodesonar/core';

const poller = new Poller({ timeout: 2 });

// Poll a single host every 5 seconds
poller.pollHost({ host: '192.168.1.1', interval: 5000 }, (res) => {
  console.log(`${res.host} is ${res.status}`);
  console.log(`Packets — sent: ${res.count}, received: ${res.packetsReceived}, loss: ${res.packetLoss * 100}%`);

  if (res.latency) {
    console.log(`Latency — avg: ${res.latency.average}ms, fastest: ${res.latency.fastest}ms, slowest: ${res.latency.slowest}ms`);
  }
});

// Poll multiple hosts simultaneously
poller.pollHost({ host: '192.168.1.2', interval: 2000 }, (res) => {
  console.log(res);
});

// Check which hosts are currently being polled
console.log(poller.activeHosts); // ['192.168.1.1', '192.168.1.2']

// Stop polling a specific host
poller.stopPolling('192.168.1.1');

// Stop all polling
poller.stopAll();

Ping a host directly

import { Poller } from '@nodesonar/core';

const poller = new Poller();

const result = await poller.pingHost('192.168.1.1');
console.log(result);
// {
//   host: '192.168.1.1',
//   isReachable: true,
//   status: 'Online',
//   count: 4,
//   packetsReceived: 4,
//   latency: {
//     average: 4.2,
//     fastest: 3.1,
//     slowest: 5.8
//   },
//   packetLoss: 0,
//   output: '...'
// }

// When host is unreachable
// {
//   host: '192.168.1.1',
//   isReachable: false,
//   status: 'Offline',
//   count: 4,
//   packetsReceived: 0,
//   latency: null,
//   packetLoss: 1,
//   output: '...'
// }

IPScanner — Discover devices on your network

import { IPScanner } from '@nodesonar/core';

const scanner = new IPScanner({ timeout: 2 });

// Scan a range and get all discovered devices
const devices = await scanner.discover('192.168.1.0/24');
console.log(devices);

// Stream devices as they are found
const devices = await scanner.discover('192.168.1.0-255', (device) => {
  console.log(`Found: ${device.host}`);
});

Supported range formats:

| Format | Example | |---|---| | CIDR | 192.168.1.0/24 | | Short dash | 192.168.1.0-255 | | Full IP range | 192.168.1.0-192.168.1.100 | | Wildcard | 192.168.1.* | | Single IP | 192.168.1.1 |


API

Poller

| Method | Description | |---|---| | pollHost(config, cb) | Polls a host at the specified interval, invoking the callback with each result. | | stopPolling(host) | Stops polling the specified host. | | stopAll() | Stops all active polling intervals. | | pingHost(host) | Pings a host once and returns the result. | | activeHosts | Returns a list of hosts currently being polled. | | config | Returns the current poller configuration. |


IPScanner

| Method | Description | |---|---| | discover(range, onDeviceFound?) | Scans the given IP range and returns all reachable devices. Optionally streams results via callback. |


Types

PingHost.Response

interface Response {
  host: string;
  status: 'Online' | 'Offline';
  isReachable: boolean;
  count: number;
  packetsReceived: number;
  latency: {
    average: number;
    fastest: number;
    slowest: number;
  } | null;
  packetLoss: number; // 0–1 (e.g. 0.75 = 75% loss)
  output: string;
}

PingHost.Options

interface Options {
  count?: number;
  timeout?: number;
  packetSize?: number;
  extra?: string[];
}

PingHost.PollHostConfig

interface PollHostConfig {
  host: string;
  interval?: number; // ms, default 1000
}

IPScan.Discovered

type Discovered = Pick<PingHost.Response, 'host' | 'latency'>;

Requirements

  • Node.js 22+
  • On Linux, raw socket access may require running with sudo or granting cap_net_raw capabilities

License

ISC