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

lan-discovery

v1.0.6

Published

Cross-platform local network library to scan lan and determine device informations (using ping and arp)

Readme

lan-discovery

Installation

$ npm install lan-discovery --save
$ node test.js

Usage

Example - Hybrid Scan (ARP Broadcast + Ping) - Recommended

Low-impact method: ARP broadcast first to discover active devices, then ping only on discovered IPs.

const LanDiscovery = require('lan-discovery');
let discovery = new LanDiscovery({ verbose: false, timeout: 60 });

// Listen to ARP discovery events
discovery.on(LanDiscovery.EVENT_ARP_RESPONSE, (device) => {
	console.log('ARP discovered:', device.ip, device.mac);
});

// Listen to ping and device info events
discovery.on(LanDiscovery.EVENT_DEVICE_INFOS, (device) => {
	console.log('Device info:', device); // { ip, mac, name, alive: true }
});

discovery.on(LanDiscovery.EVENT_DEVICES_INFOS, (devices) => {
	console.log('All devices:', devices.length, 'found');
});

let myInterface = await discovery.getDefaultInterface();
await discovery.startHybridScan({ 
	networkInterface: myInterface,
	timeout: 3000,
	interval: 100
});

Note:

  • Linux/macOS/Windows: If no administrator rights, throws an error.
  • Linux/macOS: For ARP broadcast, use scan-arp command (sudo apt install arp-scan)
  • Windows: For ARP broadcast, use third_party/scan-arp.exe (packed in the application)

Example - Standard Scan (ICMP on all IPs), more impact on network but no administrator rights required

const LanDiscovery = require('lan-discovery');
let discovery = new LanDiscovery({ verbose: false, timeout: 60 });
discovery.on(LanDiscovery.EVENT_DEVICE_INFOS, (device) => {
	console.log('--> event '+ LanDiscovery.EVENT_DEVICE_INFOS +' :\n', device);
});

let myInterface = await discovery.getDefaultInterface();
let tabIP = LanDiscovery.cidrRange(myInterface.cidr);
discovery.startScan({ ipArrayToScan: tabIP, interval: 100 });

EVENTS

EVENT_SCAN_RESPONSE : one device just responded to ping EVENT_DEVICE_INFOS : we juste retrieve one device informations EVENT_SCAN_COMPLETE : ping scan complete EVENT_DEVICES_INFOS : we retrieve all devices informations EVENT_ARP_RESPONSE : one device discovered via ARP broadcast (device = {ip, mac}) EVENT_ARP_COMPLETE : ARP broadcast scan complete


async arpTable(): Promise<Array>

Retrieves the network's arp table


async deviceInfos(): Promise<Object>

Get all informations about a device identified by his IP address


async deviceIP(mac: string): Promise<string | null>

Get the IP address for given MAC address Warning : can return null if the lan has not been scanned recently


async deviceMAC(ip: string): Promise<string | null>

Get the MAC address for given IP address Warning : can return null if you haven't previously send a ping request


async deviceName(ip: string): Promise<string | null>

Get hostname from ip address


async getDefaultInterface(): Promise<Object>

Return active network informations


isIP(ip: string): boolean

Checks if an IP address is valid


isMAC(mac: string): boolean

Checks if a MAC address is valid


async startScan(objParam): Promise<This>

Start the lan scan (Node ICMP Requests) and return promise resolving the network scan.

Requirements:

  • All platforms (priority): raw-socket package for efficient ping session via net-ping
    • The raw-socket package is included in dependencies and will be installed automatically

async startHybridScan(objParam): Promise<This>

Start hybrid scan: Instead of scanning all IPs, ARP broadcast first (L2 low impact), then ping (L3) only on discovered IPs. Return promise resolving the network scan.

Requirements:

  • All platforms (priority): raw-socket package for efficient ping session via net-ping
    • The raw-socket package is included in dependencies and will be installed automatically
  • Windows: administrator rights
  • Linux/macOS: administrator rights, arp-scan command (sudo apt install arp-scan)

Credits

This librarie is heavyly inspired from theses modules :

  • device-discovery (Mark Tiedemann)
  • arpping (haf-decent)
  • @network-utils/arp-lookup (Justin Taddei)
  • @network-utils/tcp-ping (Justin Taddei)
  • default-gateway (Sindre Sorhus)

... but re-writed to fit my needs :

  • get ip/mac/name with one cross platform librarie (at least linux and windows)
  • no more nmap dependencies
  • use of nodejs ping implementation (net-ping) to keep performance
  • use of ES8 keyword async/await
  • use class and class inheritance
  • use of event pattern

On linux/macOS, we use arp-scan command available at https://github.com/royhills (Roy Hills) On windows, we use arp-scan.exe available at https://github.com/QbsuranAlang (Qbsuran Alang)

License

MIT