/ipv4-converter

convert IPv4 address to 32bit integer isomorphically

Primary LanguageJavaScriptMIT LicenseMIT

IPv4 Converter

convert string into a 32-bit integer.

Spec

For example, given an IP address “172.168.5.1”, the output should be a 32-bit integer with “172” as the highest order 8 bit, 168 as the second highest order 8 bit, 5 as the second lowest order 8 bit, and 1 as the lowest order 8 bit. That is,

"172.168.5.1" => 2896692481

Validation

a string with spaces between a digit and a dot is a valid input; while a string with spaces between two digits is not.

  • "172[Space].[Space]168.5.1" is a valid input. Should process the output normally.
  • "1[Space]72.168.5.1" is not a valid input. Should report an error.

Run in local

yarn install
yarn dev
open index.html

Test

yarn test

License

MIT