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

iplib-js

v2.1.0

Published

IPlib.js is a JavaScript library very inspired by the IPlib python module useful to convert amongst many different notations and to manage couples of address/netmask in the CIDR notation.

Downloads

4

Readme

iplib.js

IPlib.js is a JavaScript library very inspired by the IPlib python module useful to convert amongst many different notations and to manage couples of address/netmask in the CIDR notation.

Copyright

Copyright (c) 2012-2017 Endian S.p.A. <[email protected]>
Endian S.p.A.
via Pillhof 47
39057 Appiano (BZ)
Italy

IPlib.js is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version.

IPlib.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with IPlib.js. If not, see http://www.gnu.org/licenses/.

Author: Andrea Bonomi [email protected]

Usage

Include the JavaScript library in your HTML markup:

<script type="text/javascript" src="iplib.js"></script>

CIDR

Create CIDR instances, same address, different styles:

const c = new iplib.CIDR("192.168.0.0/24");
const d = new iplib.CIDR("192.168.0.0/255.255.255.0");
const e = new iplib.CIDR("11000000101010000000000000000000/24");
const f = new iplib.CIDR("11000000101010000000000000000000/255.255.255.0");
const g = new iplib.CIDR("11000000101010000000000000000000/11111111111111111111111100000000");

Compare the two CIDR object:

c.equals(d)

Get the network IP, netmask, first IP, last IP, and broadcast address:

c.getNetworkIp()
c.getNetmask()
c.getFirstIp()
c.getLastIp()
c.getBroadcastIp()

Get the number of IPs of the network:

c.getIpNumber()

Get the CIDR IP address and netmask in different styles:

c.ip.getDec() // e.g. 3232235520
c.ip.getDot() // e.g. 192.168.0.0
c.ip.getBin() // e.g. 11000000101010000000000000000000
c.nm.getDec() // e.g. 4294967040
c.nm.getDot() // e.g. 255.255.255.0
c.nm.getBit() // e.g. 11111111111111111111111100000000
c.nm.getBits() // e.g. 24

Check if the given address in amongst the usable addresses.

const c = new iplib.CIDR("192.168.0.0/24");
c.isValidIp("192.168.0.2");

Check if one CIDR is contained in another one.

const c = new iplib.CIDR("192.168.0.0/24");
c.isValidIp("192.168.0.0/29");

Get all the IP addresses.

const c = new iplib.CIDR("192.168.0.0/24");
for (const ip of c) {
  console.log(ip);
}

IPv4Address

Create IPv4Address instances, same address, different styles:

const c = new iplib.IPv4Address("172.16.20.2");
const d = new iplib.IPv4Address("172.16.20.2", iplib.IP_DOT);
const e = new iplib.IPv4Address("10101100000100000001010000000010");
const f = new iplib.IPv4Address("10101100000100000001010000000010", iplib.IP_BIN);
const g = new iplib.IPv4Address(2886734850);
const h = new iplib.IPv4Address(2886734850, iplib.IP_DEC);

Compare the two IPv4Address object:

c.equals(d)

Get the IP address in different styles:

c.ip.getDec() // e.g. 2886734850
c.ip.getDot() // e.g. 172.16.20.2
c.ip.getBin() // e.g. 10101100000100000001010000000010