Use arrow functions for callbacks.

This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
This commit is contained in:
Jacob Trimble
2019-05-08 09:43:59 -07:00
parent f5701e7b3b
commit 47daf49f31
129 changed files with 2307 additions and 2306 deletions
+17 -17
View File
@@ -15,10 +15,10 @@
* limitations under the License.
*/
describe('StringUtils', function() {
describe('StringUtils', () => {
const StringUtils = shaka.util.StringUtils;
it('parses fromUTF8', function() {
it('parses fromUTF8', () => {
// This is 4 Unicode characters, the last will be split into a surrogate
// pair.
const arr = [0x46, 0xe2, 0x82, 0xac, 0x20, 0xf0, 0x90, 0x8d, 0x88];
@@ -26,7 +26,7 @@ describe('StringUtils', function() {
expect(StringUtils.fromUTF8(buffer)).toBe('F\u20ac \ud800\udf48');
});
it('strips the BOM in fromUTF8', function() {
it('strips the BOM in fromUTF8', () => {
// This is 4 Unicode characters, the last will be split into a surrogate
// pair.
const arr = [0xef, 0xbb, 0xbf, 0x74, 0x65, 0x78, 0x74];
@@ -35,7 +35,7 @@ describe('StringUtils', function() {
expect(StringUtils.fromUTF8(buffer)).toBe(ContentType.TEXT);
});
it('parses fromUTF16 big-endian', function() {
it('parses fromUTF16 big-endian', () => {
// This is big-endian pairs of 16-bit numbers. This translates into 3
// Unicode characters where the last is split into a surrogate pair.
const arr = [0x00, 0x46, 0x38, 0x01, 0xd8, 0x01, 0xdc, 0x37];
@@ -43,7 +43,7 @@ describe('StringUtils', function() {
expect(StringUtils.fromUTF16(buffer, false)).toBe('F\u3801\ud801\udc37');
});
it('parses fromUTF16 little-endian', function() {
it('parses fromUTF16 little-endian', () => {
// This is little-endian pairs of 16-bit numbers. This translates into 3
// Unicode characters where the last is split into a surrogate pair.
const arr = [0x46, 0x00, 0x01, 0x38, 0x01, 0xd8, 0x37, 0xdc];
@@ -51,44 +51,44 @@ describe('StringUtils', function() {
expect(StringUtils.fromUTF16(buffer, true)).toBe('F\u3801\ud801\udc37');
});
describe('fromBytesAutoDetect', function() {
it('detects UTF-8 BOM', function() {
describe('fromBytesAutoDetect', () => {
it('detects UTF-8 BOM', () => {
const arr = [0xef, 0xbb, 0xbf, 0x46, 0x6f, 0x6f];
const buffer = new Uint8Array(arr).buffer;
expect(StringUtils.fromBytesAutoDetect(buffer)).toBe('Foo');
});
it('detects UTF-16 BE BOM', function() {
it('detects UTF-16 BE BOM', () => {
const arr = [0xfe, 0xff, 0x00, 0x46, 0x00, 0x6f, 0x00, 0x6f];
const buffer = new Uint8Array(arr).buffer;
expect(StringUtils.fromBytesAutoDetect(buffer)).toBe('Foo');
});
it('detects UTF-16 LE BOM', function() {
it('detects UTF-16 LE BOM', () => {
const arr = [0xff, 0xfe, 0x46, 0x00, 0x6f, 0x00, 0x6f, 0x00];
const buffer = new Uint8Array(arr).buffer;
expect(StringUtils.fromBytesAutoDetect(buffer)).toBe('Foo');
});
it('guesses UTF-8', function() {
it('guesses UTF-8', () => {
const arr = [0x46, 0x6f, 0x6f];
const buffer = new Uint8Array(arr).buffer;
expect(StringUtils.fromBytesAutoDetect(buffer)).toBe('Foo');
});
it('guesses UTF-16 BE', function() {
it('guesses UTF-16 BE', () => {
const arr = [0x00, 0x46, 0x00, 0x6f, 0x00, 0x6f];
const buffer = new Uint8Array(arr).buffer;
expect(StringUtils.fromBytesAutoDetect(buffer)).toBe('Foo');
});
it('guesses UTF-16 LE', function() {
it('guesses UTF-16 LE', () => {
const arr = [0x46, 0x00, 0x6f, 0x00, 0x6f, 0x00];
const buffer = new Uint8Array(arr).buffer;
expect(StringUtils.fromBytesAutoDetect(buffer)).toBe('Foo');
});
it('fails if unable to guess', function() {
it('fails if unable to guess', () => {
try {
const arr = [0x01, 0x02, 0x03, 0x04];
const buffer = new Uint8Array(arr).buffer;
@@ -101,28 +101,28 @@ describe('StringUtils', function() {
});
});
it('converts toUTF8', function() {
it('converts toUTF8', () => {
const str = 'Xe\u4524\u1952';
const arr = [0x58, 0x65, 0xe4, 0x94, 0xa4, 0xe1, 0xa5, 0x92];
const buffer = StringUtils.toUTF8(str);
expect(new Uint8Array(buffer)).toEqual(new Uint8Array(arr));
});
it('converts toUTF16-LE', function() {
it('converts toUTF16-LE', () => {
const str = 'Xe\u4524\u1952';
const arr = [0x58, 0, 0x65, 0, 0x24, 0x45, 0x52, 0x19];
const buffer = StringUtils.toUTF16(str, /* littleEndian */ true);
expect(new Uint8Array(buffer)).toEqual(new Uint8Array(arr));
});
it('converts toUTF16-BE', function() {
it('converts toUTF16-BE', () => {
const str = 'Xe\u4524\u1952';
const arr = [0, 0x58, 0, 0x65, 0x45, 0x24, 0x19, 0x52];
const buffer = StringUtils.toUTF16(str, /* littleEndian */ false);
expect(new Uint8Array(buffer)).toEqual(new Uint8Array(arr));
});
it('does not cause stack overflow, #335', function() {
it('does not cause stack overflow, #335', () => {
const buffer = new Uint8Array(8e5).buffer; // Well above arg count limit.
expect(StringUtils.fromUTF8(buffer).length).toBe(buffer.byteLength);
expect(StringUtils.fromUTF16(buffer, true).length)