ip-string-to-number
v1.0.2
Published
A simple tool, that helps you to convert ipv4 or ipv6 string to number (Int or BigInt)
Downloads
58
Readme
ip-string-to-number ·
Simple helper functions for converting IP addresses from human-readable string to integers. IPv6 support included!
Usage
IPv4
const { ipV4StringToNumber } = require('ip-string-to-number');
ipV4StringToNumber('8.8.8.8'); // 134744072
IPv6
Result will be always bigint, as IPv6 address value can overcome MAX_SAFE_INTEGER in JS.
const { ipV6StringToNumber } = require('ip-string-to-number');
ipV6StringToNumber('::1'); // 1n