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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mobile-outfitters/node-networker

v1.3.5

Published

A node.js library for managing network connections. Connect/disconnect from networks and view network interfaces.

Downloads

7

Readme

Node Networker

Node Networker is a Node.js wrapper for managing network interfaces across platforms. It provides a unified API for interacting with network interfaces and wifi networks on both Linux and Windows.

Installation

To install node-networker, you can run the following commands:

yarn: yarn add @mobile-outfitters/node-networker npm: npm i @mobile-outfitters/node-networker

Electron Support

Currently, Electron does work with this package.

Example Usage

Here's a simple example of how to use node-networker:

import { networker, NetworkInterfaceType } from '@mobile-outfitters/node-networker';

const main = async () => {
    const nw = networker({});

    // get network interfaces
    const interfaces = await nw.listNetworkInterfaces();

    // Find what wifi network is currently connected
    const wifiInterface = interfaces.find((nwInterface) => nwInterface.interfaceType === NetworkInterfaceType.Wifi);
    console.log('My wifi network connected is: ', wifiInterface ? wifiInterface.networkName : 'None Found!');

    // Find ethernet interface and get the internet status
    const ethernetInterface = interfaces.find(
        (nwInterface) => nwInterface.interfaceType === NetworkInterfaceType.Ethernet
    );
    console.log(
        ethernetInterface
            ? `I have an ethernet network connected, internet status: '${ethernetInterface.internetStatus}`
            : 'I do not have an ethernet network connected!'
    );

    // get wifi networks
    const networks = await nw.listWifiNetworks();
    console.log(`I have these wifi networks available: ${networks}`);

    const internet = await nw.internetStatus();
    console.log(`I have an internet status of: ${internet}`);

    // connect to a wifi network
    await nw.connectWifi({ ssid: 'my-wifi-network', password: 'my-wifi-password' });
    console.log('I am now connected to my wifi network!');

    // disconnect from wifi
    await nw.disconnectWifi();
};

main();

Typings

Node-networker provides TypeScript typings for all its exported functions and objects. You can find these typings in src/types.ts.

Windows

Node-networker uses a native Node addon for interacting with the Windows network API. It supports the following windows versions:

  • Windows 8.1
  • Windows 10
  • Windows 11

The windows node-addon built using node-gyp and the source code can be found in the src/_windows/addon/src directory. The resulting .node binary is output to the src/_windows/addon/output.

Linux

Node-networker uses nmcli to interact with the network interfaces. nmcli is a command-line interface for NetworkManager and is pre-installed on most Linux distributions.

MacOS

Node-networker uses airport, ipconfig, and networksetup. The MacOS version is currently experimental and may not be fully reliable.

Building

In order to build the project without re-building the windows binary yarn: yarn run build npm: npm run build

If you made changes to the windows addon yarn: yarn run build-windows-binary npm: npm run build-windows-binary

Testing

Node-networker includes unit tests which mocks the outputs from either nmcli or the native node addon. To run tests: yarn: yarn run test npm: npm run test