Attributes
Includes Deno configuration
Repository
Current version released
3 years ago
Dependencies
other
Versions
Useage
Deno
import * as netTools from "https://deno.land/x/cidr/mod.js"API
import { isCIDRv4, isIP, isIPv4, isIPv4InCIDR } from "https://deno.land/x/cidr/mod.js"
// isIP returns `number`. It will return `0` if params isn't v4 or v6
isIP('::1') // returns 6
isIP('127.0.0.1') // returns 4
isIP('127.000.000.001') // returns 0
isCIDRv4("192.168.50.1/16") // true
isCIDRv4("192.168.50.1") // false
isIPv4InCIDR('192.168.50.1/16', '192.168.50.12') // trueYou can use isIPv4 if you only want to determine whether an IP is IPv4, it returns boolean.
isIPv4InCIDR is to determine whether an IP is within the CIDR range. The first parameter is CIDR range, the second paramter is IP address.