Skip to content

Instantly share code, notes, and snippets.

@jingyuexing
Created August 27, 2022 09:47
Show Gist options
  • Save jingyuexing/cc6795947dfdb011b6c16cc518bfd608 to your computer and use it in GitHub Desktop.
Save jingyuexing/cc6795947dfdb011b6c16cc518bfd608 to your computer and use it in GitHub Desktop.
/**
* [IParser description]
* @param {string} ip IPv4 string
*/
function IParser(ip) {
let ipValue = 0
let temp = ip.split(".");
for (let i = 0; i < temp.length; i++) {
ipValue += Number(temp[i]) * Math.pow(0x100, 3 - i)
}
return ipValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment