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

punycode: fix jsdoc references #45524

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ function error(type) {
* item.
* @returns {Array} A new array of values returned by the callback function.
*/
function map(array, fn) {
function map(array, callback) {
const result = [];
let length = array.length;
while (length--) {
result[length] = fn(array[length]);
result[length] = callback(array[length]);
}
return result;
}
Expand All @@ -76,22 +76,22 @@ function map(array, fn) {
* @param {String} domain The domain name or email address.
* @param {Function} callback The function that gets called for every
* character.
* @returns {Array} A new string of characters returned by the callback
* @returns {String} A new string of characters returned by the callback
* function.
*/
function mapDomain(string, fn) {
const parts = string.split('@');
function mapDomain(domain, callback) {
const parts = domain.split('@');
let result = '';
if (parts.length > 1) {
// In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact.
result = parts[0] + '@';
string = parts[1];
domain = parts[1];
}
// Avoid `split(regex)` for IE8 compatibility. See #17.
string = string.replace(regexSeparators, '\x2E');
const labels = string.split('.');
const encoded = map(labels, fn).join('.');
domain = domain.replace(regexSeparators, '\x2E');
const labels = domain.split('.');
const encoded = map(labels, callback).join('.');
return result + encoded;
}

Expand Down Expand Up @@ -140,7 +140,7 @@ function ucs2decode(string) {
* @param {Array} codePoints The array of numeric code points.
* @returns {String} The new Unicode string (UCS-2).
*/
const ucs2encode = array => String.fromCodePoint(...array);
const ucs2encode = codePoints => String.fromCodePoint(...codePoints);

/**
* Converts a basic code point into a digit/integer.
Expand Down