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

@webpod/ip

v0.6.1

Published

Lite IP tools

Readme

@webpod/ip

Lite IP tools

This lib is an alternative for the ip package which resolves many upstream issues.

  • Reforged in TypeScript
  • Provides both ESM and CJS entries
  • Exposes browser-compatible ./core
  • Eliminates annoying vulnerabilities CVE-2024-29415, CVE-2023-42282
  • Brings various fixes, improvements and optimizations
  • Enterprise ready

Install

npm i @webpod/ip

Drop-in

- const ip = require('ip')
+ const ip = require('@webpod/ip')

Temporary workaround to avoid refactoring is using overrides / resolutions in your package.json:

{
  "overrides": {
    "ip": "@webpod/ip"
  }
}

Browser-compatible core build is available as @webpod/ip/core: it omits node:os dependency and polyfills the Buffer API.

Strict mode

By default, the library is in the strict mode that rejects non-canonical embedded IPv4 in IPv6. Switch to legacy flow if needed:

import { Address } from '@webpod/ip'

Address.from('::ffff:5.6.7.8')    // ok
Address.from('1:2:3:4::5.6.7.8')  // throws

Address.strict = false
Address.from('1:2:3:4::5.6.7.8')  // now it's fine

Usage

The API is fully compatible with the latest [email protected] but enforces stricter validations. See coherence.md for details.

import ip from '@webpod/ip'

// -------------------------------------------------------
// Addresses & formats
// -------------------------------------------------------

ip.address()                              // '192.168.1.50'  (example local address)
ip.isPrivate('127.0.0.1')                 // true
ip.isV4Format('127.0.0.1')                // true
ip.isV6Format('::ffff:127.0.0.1')         // true
ip.isEqual('::1', '::0:1')                // true

// -------------------------------------------------------
// Conversions
// -------------------------------------------------------

ip.toBuffer('127.0.0.1')                  // <Buffer 7f 00 00 01>
ip.toString(Buffer.from([127, 0, 0, 1]))  // '127.0.0.1'

ip.toLong('127.0.0.1')                    // 2130706433
ip.fromLong(2130706433)                   // '127.0.0.1'

ip.fromPrefixLen(24)                      // '255.255.255.0'

// in-place buffer usage
const buf = Buffer.alloc(128)
const offset = 64
ip.toBuffer('127.0.0.1', buf, offset)     // writes [127, 0, 0, 1] at offset 64
ip.toString(buf, offset, 4)               // '127.0.0.1'

// -------------------------------------------------------
// Masking, bitwise, and ranges
// -------------------------------------------------------

ip.mask('192.168.1.134', '255.255.255.0') // '192.168.1.0'
ip.cidr('192.168.1.134/26')               // '192.168.1.128'
ip.not('255.255.255.0')                   // '0.0.0.255'
ip.or('192.168.1.134', '0.0.0.255')       // '192.168.1.255'

// -------------------------------------------------------
// Subnets
// -------------------------------------------------------

ip.subnet('192.168.1.134', '255.255.255.192')
/*
{
  networkAddress:   '192.168.1.128',
  firstAddress:     '192.168.1.129',
  lastAddress:      '192.168.1.190',
  broadcastAddress: '192.168.1.191',
  subnetMask:       '255.255.255.192',
  subnetMaskLength: 26,
  numHosts:         62,
  length:           64,
  contains: [Function: contains]
}
*/

ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true

Address class

import { Address } from '@webpod/ip'

// -------------------------------------------------------
// Prototype methods
// -------------------------------------------------------

const addr4 = Address.from('192.168.1.134')

addr4.family        // 4
addr4.big           // 323223590n
addr4.toString()    // '192.168.1.134'
addr4.toLong()      // 323223590
addr4.toBuffer()    // <Buffer c0 a8 01 86>
addr4.toArray()     // [192, 168, 1, 134]

const addr6 = Address.from('::1')

addr6.family        // 6
addr6.big           // 1n
addr6.toString()    // '::1'
addr6.toString(4)   // '0.0.0.1'
addr6.toBuffer().toString('hex') // '00000000000000000000000000000001'

// -------------------------------------------------------
// Specific ranges check
// -------------------------------------------------------

Address.from('127.0.0.1').range                   // 'loopback'
Address.from('192.0.2.10').range                  // 'documentation'

Address.isSpecial('127.0.0.1')                    // true
Address.isSpecial('127.0.0.1', 'loopback')        // true
Address.isSpecial('127.0.0.1', 'documentation')   // false
Address.isSpecial('1.2.3.4')                      // false

Alternatives

Follow coherence.md, benchmark.md and meta.md to explore suitable options.

License

MIT