MCPcopy
hub / github.com/di-sukharev/opencommit / parseIPv4

Function parseIPv4

out/cli.cjs:3684–3717  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

3682 return parseInt(input, R7);
3683 }
3684 function parseIPv4(input) {
3685 const parts = input.split(".");
3686 if (parts[parts.length - 1] === "") {
3687 if (parts.length > 1) {
3688 parts.pop();
3689 }
3690 }
3691 if (parts.length > 4) {
3692 return failure;
3693 }
3694 const numbers = [];
3695 for (const part of parts) {
3696 const n2 = parseIPv4Number(part);
3697 if (n2 === failure) {
3698 return failure;
3699 }
3700 numbers.push(n2);
3701 }
3702 for (let i3 = 0; i3 < numbers.length - 1; ++i3) {
3703 if (numbers[i3] > 255) {
3704 return failure;
3705 }
3706 }
3707 if (numbers[numbers.length - 1] >= 256 ** (5 - numbers.length)) {
3708 return failure;
3709 }
3710 let ipv4 = numbers.pop();
3711 let counter = 0;
3712 for (const n2 of numbers) {
3713 ipv4 += n2 * 256 ** (3 - counter);
3714 ++counter;
3715 }
3716 return ipv4;
3717 }
3718 function serializeIPv4(address) {
3719 let output = "";
3720 let n2 = address;

Callers 1

parseHostFunction · 0.85

Calls 2

parseIPv4NumberFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…