| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ee4186b commit b353ded
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1479,9 +1479,17 @@ added: v0.3.0 | |||
| 1479 | 1479 | * `input` {string} | |
| 1480 | 1480 | * Returns: {integer} | |
| 1481 | 1481 | ||
| 1482 | - Tests if input is an IP address. Returns `0` for invalid strings, | ||
| 1483 | - returns `4` for IP version 4 addresses, and returns `6` for IP version 6 | ||
| 1484 | - addresses. | ||
| 1482 | + Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4 | ||
| 1483 | + address in [dot-decimal notation][] with no leading zeroes. Otherwise, returns | ||
| 1484 | + `0`. | ||
| 1485 | + | ||
| 1486 | + ```js | ||
| 1487 | + net.isIP('::1'); // returns 6 | ||
| 1488 | + net.isIP('127.0.0.1'); // returns 4 | ||
| 1489 | + net.isIP('127.000.000.001'); // returns 0 | ||
| 1490 | + net.isIP('127.0.0.1/24'); // returns 0 | ||
| 1491 | + net.isIP('fhqwhgads'); // returns 0 | ||
| 1492 | + ``` | ||
| 1485 | 1493 | ||
| 1486 | 1494 | ## `net.isIPv4(input)` | |
| 1487 | 1495 | ||
@@ -1492,7 +1500,15 @@ added: v0.3.0 | |||
| 1492 | 1500 | * `input` {string} | |
| 1493 | 1501 | * Returns: {boolean} | |
| 1494 | 1502 | ||
| 1495 | - Returns `true` if input is a version 4 IP address, otherwise returns `false`. | ||
| 1503 | + Returns `true` if `input` is an IPv4 address in [dot-decimal notation][] with no | ||
| 1504 | + leading zeroes. Otherwise, returns `false`. | ||
| 1505 | + | ||
| 1506 | + ```js | ||
| 1507 | + net.isIPv4('127.0.0.1'); // returns true | ||
| 1508 | + net.isIPv4('127.000.000.001'); // returns false | ||
| 1509 | + net.isIPv4('127.0.0.1/24'); // returns false | ||
| 1510 | + net.isIPv4('fhqwhgads'); // returns false | ||
| 1511 | + ``` | ||
| 1496 | 1512 | ||
| 1497 | 1513 | ## `net.isIPv6(input)` | |
| 1498 | 1514 | ||
@@ -1503,7 +1519,12 @@ added: v0.3.0 | |||
| 1503 | 1519 | * `input` {string} | |
| 1504 | 1520 | * Returns: {boolean} | |
| 1505 | 1521 | ||
| 1506 | - Returns `true` if input is a version 6 IP address, otherwise returns `false`. | ||
| 1522 | + Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`. | ||
| 1523 | + | ||
| 1524 | + ```js | ||
| 1525 | + net.isIPv6('::1'); // returns true | ||
| 1526 | + net.isIPv6('fhqwhgads'); // returns false | ||
| 1527 | + ``` | ||
| 1507 | 1528 | ||
| 1508 | 1529 | [IPC]: #ipc-support | |
| 1509 | 1530 | [Identifying paths for IPC connections]: #identifying-paths-for-ipc-connections | |
@@ -1557,6 +1578,7 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`. | |||
| 1557 | 1578 | [`writable.destroyed`]: stream.md#writabledestroyed | |
| 1558 | 1579 | [`writable.end()`]: stream.md#writableendchunk-encoding-callback | |
| 1559 | 1580 | [`writable.writableLength`]: stream.md#writablewritablelength | |
| 1581 | + [dot-decimal notation]: https://en.wikipedia.org/wiki/Dot-decimal_notation | ||
| 1560 | 1582 | [half-closed]: https://tools.ietf.org/html/rfc1122 | |
| 1561 | 1583 | [stream_writable_write]: stream.md#writablewritechunk-encoding-callback | |
| 1562 | 1584 | [unspecified IPv4 address]: https://en.wikipedia.org/wiki/0.0.0.0 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments