Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intToIp converter to network #360

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dimon-durak
Copy link

  • code is properly formatted (npm run fmt)
  • tests are added/updated
  • documentation is updated (npm run doc to regenerate documentation based on comments)
  • description of changes is added under the Unreleased header in CHANGELOG.md

@dimon-durak dimon-durak changed the title add intToIp converter to network Add intToIp converter to network Dec 9, 2020
Copy link
Member

@tshemsedinov tshemsedinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -8,6 +8,8 @@ and this project adheres to

## [Unreleased][unreleased]

- add intToIp converter to network
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- add intToIp converter to network
- Add `intToIp` converter to `network.js`

Comment on lines +5 to +7
// Convert IPv4 address from string form to number form
// Signature: IP_string
// IP_string - <string>, (optional), default: '127.0.0.1', IPv4 address in string form
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Convert IPv4 address from string form to number form
// Signature: IP_string
// IP_string - <string>, (optional), default: '127.0.0.1', IPv4 address in string form
// Convert IPv4 address from string form to number form
// Signature: [ip]
// ip - <string>, (optional), default: '127.0.0.1', IPv4 address in string form

Comment on lines +12 to +14
// Convert IPv4 address from number form to string form
// Signature: IP_number
// IP_number - <number>, (optional), default: 0, IPv4 address in number form
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Convert IPv4 address from number form to string form
// Signature: IP_number
// IP_number - <number>, (optional), default: 0, IPv4 address in number form
// Convert IPv4 address from number form to string form
// Signature: [ip]
// ip - <number>, (optional), default: 0, IPv4 address in number form

Comment on lines +16 to +19
const intToIp = (ipInt = 0) =>
[ipInt >>> 24, (ipInt >> 16) & 255, (ipInt >> 8) & 255, ipInt & 255].join(
'.'
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to put 4 parts of address into 4 separate variables and concatenate them without creating array and call join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants