Skip to content

Commit 4fb9177

Browse files
committed
style: lint
1 parent 2f7970b commit 4fb9177

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

lib/_browser/decode.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ function utf8Read ( view, offset, length ) {
44
for ( var i = offset, end = offset + length; i < end; i++ ) {
55
var byte = view.getUint8( i );
66
if ( ( byte & 0x80 ) === 0x00 ) {
7-
string += String.fromCharCode( byte );
7+
string += String.fromCodePoint( byte );
88
continue;
99
}
1010
if ( ( byte & 0xE0 ) === 0xC0 ) {
11-
string += String.fromCharCode( ( ( byte & 0x1F ) << 6 ) | ( view.getUint8( ++i ) & 0x3F ) );
11+
string += String.fromCodePoint( ( ( byte & 0x1F ) << 6 ) | ( view.getUint8( ++i ) & 0x3F ) );
1212
continue;
1313
}
1414
if ( ( byte & 0xF0 ) === 0xE0 ) {
15-
string += String.fromCharCode( ( ( byte & 0x0F ) << 12 ) | ( ( view.getUint8( ++i ) & 0x3F ) << 6 ) | ( ( view.getUint8( ++i ) & 0x3F ) << 0 ) );
15+
string += String.fromCodePoint( ( ( byte & 0x0F ) << 12 ) | ( ( view.getUint8( ++i ) & 0x3F ) << 6 ) | ( ( view.getUint8( ++i ) & 0x3F ) << 0 ) );
1616
continue;
1717
}
1818
if ( ( byte & 0xF8 ) === 0xF0 ) {
@@ -21,10 +21,10 @@ function utf8Read ( view, offset, length ) {
2121

2222
// surrogate pair
2323
chr -= 0x01_00_00;
24-
string += String.fromCharCode( ( chr >>> 10 ) + 0xD8_00, ( chr & 0x3_FF ) + 0xDC_00 );
24+
string += String.fromCodePoint( ( chr >>> 10 ) + 0xD8_00, ( chr & 0x3_FF ) + 0xDC_00 );
2525
}
2626
else {
27-
string += String.fromCharCode( chr );
27+
string += String.fromCodePoint( chr );
2828
}
2929
continue;
3030
}

lib/_browser/encode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function utf8Write ( view, offset, str ) {
22
var c = 0;
33
for ( var i = 0, l = str.length; i < l; i++ ) {
4-
c = str.charCodeAt( i );
4+
c = str.codePointAt( i );
55
if ( c < 0x80 ) {
66
view.setUint8( offset++, c );
77
}
@@ -16,7 +16,7 @@ function utf8Write ( view, offset, str ) {
1616
}
1717
else {
1818
i++;
19-
c = 0x1_00_00 + ( ( ( c & 0x3_FF ) << 10 ) | ( str.charCodeAt( i ) & 0x3_FF ) );
19+
c = 0x1_00_00 + ( ( ( c & 0x3_FF ) << 10 ) | ( str.codePointAt( i ) & 0x3_FF ) );
2020
view.setUint8( offset++, 0xF0 | ( c >> 18 ) );
2121
view.setUint8( offset++, 0x80 | ( ( c >> 12 ) & 0x3F ) );
2222
view.setUint8( offset++, 0x80 | ( ( c >> 6 ) & 0x3F ) );
@@ -29,7 +29,7 @@ function utf8Length ( str ) {
2929
var c = 0,
3030
length = 0;
3131
for ( var i = 0, l = str.length; i < l; i++ ) {
32-
c = str.charCodeAt( i );
32+
c = str.codePointAt( i );
3333
if ( c < 0x80 ) {
3434
length += 1;
3535
}

lib/encode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const MICRO_OPT_LEN = 32;
44
function utf8Write ( arr, offset, str ) {
55
let c = 0;
66
for ( let i = 0, l = str.length; i < l; i++ ) {
7-
c = str.charCodeAt( i );
7+
c = str.codePointAt( i );
88
if ( c < 0x80 ) {
99
arr[ offset++ ] = c;
1010
}
@@ -19,7 +19,7 @@ function utf8Write ( arr, offset, str ) {
1919
}
2020
else {
2121
i++;
22-
c = 0x1_00_00 + ( ( ( c & 0x3_FF ) << 10 ) | ( str.charCodeAt( i ) & 0x3_FF ) );
22+
c = 0x1_00_00 + ( ( ( c & 0x3_FF ) << 10 ) | ( str.codePointAt( i ) & 0x3_FF ) );
2323
arr[ offset++ ] = 0xF0 | ( c >> 18 );
2424
arr[ offset++ ] = 0x80 | ( ( c >> 12 ) & 0x3F );
2525
arr[ offset++ ] = 0x80 | ( ( c >> 6 ) & 0x3F );
@@ -33,7 +33,7 @@ function utf8Length ( str ) {
3333
let c = 0,
3434
length = 0;
3535
for ( let i = 0, l = str.length; i < l; i++ ) {
36-
c = str.charCodeAt( i );
36+
c = str.codePointAt( i );
3737
if ( c < 0x80 ) {
3838
length += 1;
3939
}

0 commit comments

Comments
 (0)