Attributes
Popular
Repository
Current version released
4 years ago
Versions
isIP
IP address detector for Deno.
Usage
import { isIPv4, isIPv6, isIP } from "https://raw.githubusercontent.com/ako-deno/isIP/master/mod.ts";
isIPv4("192.168.0.2"); // true
isIPv4("168.0.2"); // false
isIPv4("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // false
isIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // true
isIPv6("2001:0db8:85a3:0000:0000:8a2e:0370"); // false
isIPv6("192.168.0.2"); // false
isIP("192.168.0.2"); // 4
isIP("168.0.2"); // 0
isIP("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // 6
isIP("2001:0db8:85a3:0000:0000:8a2e:0370"); // 0
API
isIPv4(input: string): boolean
Returns true if input is a version 4 IP address, otherwise returns false. It should be compatible with Node.js’ net.isIPv4.
isIPv6(input: string): boolean
Returns true if input is a version 6 IP address, otherwise returns false. It should be compatible with Node.js’ net.isIPv6.
isIP(input: string): number
Tests if input is an IP address. Returns 0 for invalid strings, returns 4 for IP version 4 addresses, and returns 6 for IP version 6 addresses. It should be compatible with Node.js’ net.isIP.
Any incompatibility, please check net_isip_test.ts