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

Update punycode.js #445

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
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
30 changes: 15 additions & 15 deletions src/punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
;(function(root) {

/** Detect free variables */
var freeExports = typeof exports == 'object' && exports &&
let freeExports = typeof exports == 'object' && exports &&
!exports.nodeType && exports;
var freeModule = typeof module == 'object' && module &&
let freeModule = typeof module == 'object' && module &&
!module.nodeType && module;
var freeGlobal = typeof global == 'object' && global;
let freeGlobal = typeof global == 'object' && global;
if (
freeGlobal.global === freeGlobal ||
freeGlobal.window === freeGlobal ||
Expand All @@ -20,7 +20,7 @@
* @name punycode
* @type Object
*/
var punycode,
let punycode,

/** Highest positive signed 32-bit float value */
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
Expand Down Expand Up @@ -76,8 +76,8 @@
* @returns {Array} A new array of values returned by the callback function.
*/
function map(array, fn) {
var length = array.length;
var result = [];
let length = array.length;
let result = [];
while (length--) {
result[length] = fn(array[length]);
}
Expand All @@ -95,8 +95,8 @@
* function.
*/
function mapDomain(string, fn) {
var parts = string.split('@');
var result = '';
let parts = string.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.
Expand All @@ -105,8 +105,8 @@
}
// Avoid `split(regex)` for IE8 compatibility. See #17.
string = string.replace(regexSeparators, '\x2E');
var labels = string.split('.');
var encoded = map(labels, fn).join('.');
let labels = string.split('.');
let encoded = map(labels, fn).join('.');
return result + encoded;
}

Expand All @@ -124,7 +124,7 @@
* @returns {Array} The new array of code points.
*/
function ucs2decode(string) {
var output = [],
let output = [],
counter = 0,
length = string.length,
value,
Expand Down Expand Up @@ -159,7 +159,7 @@
*/
function ucs2encode(array) {
return map(array, function(value) {
var output = '';
let output = '';
if (value > 0xFFFF) {
value -= 0x10000;
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
Expand Down Expand Up @@ -215,7 +215,7 @@
* @private
*/
function adapt(delta, numPoints, firstTime) {
var k = 0;
let k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
Expand All @@ -233,7 +233,7 @@
*/
function decode(input) {
// Don't use UCS-2
var output = [],
let output = [],
inputLength = input.length,
out,
i = 0,
Expand Down Expand Up @@ -333,7 +333,7 @@
* @returns {String} The resulting Punycode string of ASCII-only symbols.
*/
function encode(input) {
var n,
let n,
delta,
handledCPCount,
basicLength,
Expand Down