Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

macaddress-local-machine

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

macaddress-local-machine

MAC Address Getter is a Node.js library for retrieving the MAC addresses from a machine's network interfaces. It provides functionalities to get either the first MAC address or all MAC addresses.

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-17.58%
Maintainers
1
Weekly downloads
 
Created
Source

MAC Address Getter

MAC Address Getter is a Node.js library for retrieving the MAC addresses from a machine's network interfaces. It provides functionalities to get either the first MAC address or all MAC addresses.


Installation

Use the package manager npm to install MAC Address Getter.

npm install --save-dev macaddress-local-machine
OR
yarn add -D macaddress-local-machine

Usage

import { first, all } from "macaddress-local-machine";

// Get the first MAC address
const macAddress = first();
console.log(macAddress);

// Get all MAC addresses
const macAddresses = all();
console.log(macAddresses);
OR
import macAddr from "macaddress-local-machine";
// Get the first MAC address
const macAddress = macAddr.first();
console.log(macAddress);

// Get all MAC addresses
const macAddresses = macAddr.all();
console.log(macAddresses);

Interface

interface MACAddress {
  iface: string,
  macAddr: string
}

// Example object:
{
  "iface": "eno2",
  "macAddr": "01:23:45:67:89:ab"
}
/**
 *  Returns the first MAC address found. If throwErrorIfNoneFound is set to true and no MAC 
 *  address is found, an error will be thrown.
 */
function first(throwErrorIfNoneFound: boolean = false): MACAddress | undefined;
function first(throwErrorIfNoneFound: boolean = true): MACAddress;
/**
 *  Returns an array of all MAC addresses found. If throwErrorIfNoneFound is set to true and 
 *  no MAC address is found, an error will be thrown. Otherwise, if none are found, return an
 *  empty array.
 */
function all(throwErrorIfNoneFound: boolean = true): MACAddress[]

Keywords

FAQs

Package last updated on 12 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc