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

all done #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

all done #29

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 3, 2019

No description provided.

// Use Array.prototype.reduce of for loop
};
const ipToInt = (ip = '127.0.0.1') => ip.split('.').reduce(
(sum, elem, i, arr) => sum + (Number(elem) << 8 * (arr.length - 1 - i))
Copy link

@avtohem avtohem Nov 16, 2019

Choose a reason for hiding this comment

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

Shifts a in binary representation b (< 32) bits to the left, shifting in 0s from the right.
Если массив будет больше 4 элементов, то не сработает.. хотя к IPv4 это не относится...

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.

2 participants