| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b719b77 commit 6e3a8be
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,8 +26,8 @@ const a = assert; | |||
| 26 | 26 | ||
| 27 | 27 | function makeBlock(f) { | |
| 28 | 28 | const args = Array.prototype.slice.call(arguments, 1); | |
| 29 | - return function() { | ||
| 30 | - return f.apply(this, args); | ||
| 29 | + return () => { | ||
| 30 | + return f.apply(null, args); | ||
| 31 | 31 | }; | |
| 32 | 32 | } | |
| 33 | 33 | ||
@@ -183,7 +183,7 @@ assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2)); | |||
| 183 | 183 | ||
| 184 | 184 | // having an identical prototype property | |
| 185 | 185 | const nbRoot = { | |
| 186 | - toString: function() { return `${this.first} ${this.last}`; } | ||
| 186 | + toString() { return `${this.first} ${this.last}`; } | ||
| 187 | 187 | }; | |
| 188 | 188 | ||
| 189 | 189 | function nameBuilder(first, last) { | |
@@ -458,10 +458,10 @@ assert.throws(makeBlock(thrower, TypeError)); | |||
| 458 | 458 | 'a.doesNotThrow is not catching type matching errors'); | |
| 459 | 459 | } | |
| 460 | 460 | ||
| 461 | - assert.throws(function() { assert.ifError(new Error('test error')); }, | ||
| 461 | + assert.throws(() => { assert.ifError(new Error('test error')); }, | ||
| 462 | 462 | /^Error: test error$/); | |
| 463 | - assert.doesNotThrow(function() { assert.ifError(null); }); | ||
| 464 | - assert.doesNotThrow(function() { assert.ifError(); }); | ||
| 463 | + assert.doesNotThrow(() => { assert.ifError(null); }); | ||
| 464 | + assert.doesNotThrow(() => { assert.ifError(); }); | ||
| 465 | 465 | ||
| 466 | 466 | assert.throws(() => { | |
| 467 | 467 | assert.doesNotThrow(makeBlock(thrower, Error), 'user message'); | |
@@ -501,7 +501,7 @@ assert.throws(() => { | |||
| 501 | 501 | let threw = false; | |
| 502 | 502 | try { | |
| 503 | 503 | assert.throws( | |
| 504 | - function() { | ||
| 504 | + () => { | ||
| 505 | 505 | throw ({}); // eslint-disable-line no-throw-literal | |
| 506 | 506 | }, | |
| 507 | 507 | Array | |
@@ -516,7 +516,7 @@ assert.throws(() => { | |||
| 516 | 516 | a.throws(makeBlock(thrower, TypeError), /\[object Object\]/); | |
| 517 | 517 | ||
| 518 | 518 | // use a fn to validate error object | |
| 519 | - a.throws(makeBlock(thrower, TypeError), function(err) { | ||
| 519 | + a.throws(makeBlock(thrower, TypeError), (err) => { | ||
| 520 | 520 | if ((err instanceof TypeError) && /\[object Object\]/.test(err)) { | |
| 521 | 521 | return true; | |
| 522 | 522 | } | |
@@ -619,7 +619,7 @@ testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity }, | |||
| 619 | 619 | let threw = false; | |
| 620 | 620 | try { | |
| 621 | 621 | // eslint-disable-next-line no-restricted-syntax | |
| 622 | - assert.throws(function() { | ||
| 622 | + assert.throws(() => { | ||
| 623 | 623 | assert.ifError(null); | |
| 624 | 624 | }); | |
| 625 | 625 | } catch (e) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,8 +9,8 @@ const domain = require('domain'); | |||
| 9 | 9 | */ | |
| 10 | 10 | const d = domain.create(); | |
| 11 | 11 | ||
| 12 | - d.on('error', common.mustCall(function() { | ||
| 13 | - process.nextTick(function() { | ||
| 12 | + d.on('error', common.mustCall(() => { | ||
| 13 | + process.nextTick(() => { | ||
| 14 | 14 | // Scheduling a callback with process.nextTick will enter a _new_ domain, | |
| 15 | 15 | // and the callback will be called after the domain that handled the error | |
| 16 | 16 | // was exited. So there should be only one domain on the domains stack if | |
@@ -29,6 +29,6 @@ d.on('error', common.mustCall(function() { | |||
| 29 | 29 | }); | |
| 30 | 30 | })); | |
| 31 | 31 | ||
| 32 | - d.run(function() { | ||
| 32 | + d.run(() => { | ||
| 33 | 33 | throw new Error('Error from domain'); | |
| 34 | 34 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,7 @@ const qsWeirdObjects = [ | |||
| 129 | 129 | [{ regexp: /./g }, 'regexp=', { 'regexp': '' }], | |
| 130 | 130 | // eslint-disable-next-line no-unescaped-regexp-dot | |
| 131 | 131 | [{ regexp: new RegExp('.', 'g') }, 'regexp=', { 'regexp': '' }], | |
| 132 | - [{ fn: function() {} }, 'fn=', { 'fn': '' }], | ||
| 132 | + [{ fn: () => {} }, 'fn=', { 'fn': '' }], | ||
| 133 | 133 | [{ fn: new Function('') }, 'fn=', { 'fn': '' }], | |
| 134 | 134 | [{ math: Math }, 'math=', { 'math': '' }], | |
| 135 | 135 | [{ e: extendedFunction }, 'e=', { 'e': '' }], | |
@@ -192,7 +192,7 @@ function check(actual, expected, input) { | |||
| 192 | 192 | `Expected keys: ${inspect(expectedKeys)}`; | |
| 193 | 193 | } | |
| 194 | 194 | assert.deepStrictEqual(actualKeys, expectedKeys, msg); | |
| 195 | - expectedKeys.forEach(function(key) { | ||
| 195 | + expectedKeys.forEach((key) => { | ||
| 196 | 196 | if (typeof input === 'string') { | |
| 197 | 197 | msg = `Input: ${inspect(input)}\n` + | |
| 198 | 198 | `Key: ${inspect(key)}\n` + | |
@@ -206,21 +206,21 @@ function check(actual, expected, input) { | |||
| 206 | 206 | } | |
| 207 | 207 | ||
| 208 | 208 | // test that the canonical qs is parsed properly. | |
| 209 | - qsTestCases.forEach(function(testCase) { | ||
| 209 | + qsTestCases.forEach((testCase) => { | ||
| 210 | 210 | check(qs.parse(testCase[0]), testCase[2], testCase[0]); | |
| 211 | 211 | }); | |
| 212 | 212 | ||
| 213 | 213 | // test that the colon test cases can do the same | |
| 214 | - qsColonTestCases.forEach(function(testCase) { | ||
| 214 | + qsColonTestCases.forEach((testCase) => { | ||
| 215 | 215 | check(qs.parse(testCase[0], ';', ':'), testCase[2], testCase[0]); | |
| 216 | 216 | }); | |
| 217 | 217 | ||
| 218 | 218 | // test the weird objects, that they get parsed properly | |
| 219 | - qsWeirdObjects.forEach(function(testCase) { | ||
| 219 | + qsWeirdObjects.forEach((testCase) => { | ||
| 220 | 220 | check(qs.parse(testCase[1]), testCase[2], testCase[1]); | |
| 221 | 221 | }); | |
| 222 | 222 | ||
| 223 | - qsNoMungeTestCases.forEach(function(testCase) { | ||
| 223 | + qsNoMungeTestCases.forEach((testCase) => { | ||
| 224 | 224 | assert.deepStrictEqual(testCase[0], qs.stringify(testCase[1], '&', '=')); | |
| 225 | 225 | }); | |
| 226 | 226 | ||
@@ -258,15 +258,15 @@ qsNoMungeTestCases.forEach(function(testCase) { | |||
| 258 | 258 | // now test stringifying | |
| 259 | 259 | ||
| 260 | 260 | // basic | |
| 261 | - qsTestCases.forEach(function(testCase) { | ||
| 261 | + qsTestCases.forEach((testCase) => { | ||
| 262 | 262 | assert.strictEqual(testCase[1], qs.stringify(testCase[2])); | |
| 263 | 263 | }); | |
| 264 | 264 | ||
| 265 | - qsColonTestCases.forEach(function(testCase) { | ||
| 265 | + qsColonTestCases.forEach((testCase) => { | ||
| 266 | 266 | assert.strictEqual(testCase[1], qs.stringify(testCase[2], ';', ':')); | |
| 267 | 267 | }); | |
| 268 | 268 | ||
| 269 | - qsWeirdObjects.forEach(function(testCase) { | ||
| 269 | + qsWeirdObjects.forEach((testCase) => { | ||
| 270 | 270 | assert.strictEqual(testCase[1], qs.stringify(testCase[0])); | |
| 271 | 271 | }); | |
| 272 | 272 | ||
@@ -300,7 +300,7 @@ assert.strictEqual('foo=', qs.stringify({ foo: Infinity })); | |||
| 300 | 300 | assert.strictEqual(f, 'a=b&q=x%3Dy%26y%3Dz'); | |
| 301 | 301 | } | |
| 302 | 302 | ||
| 303 | - assert.doesNotThrow(function() { | ||
| 303 | + assert.doesNotThrow(() => { | ||
| 304 | 304 | qs.parse(undefined); | |
| 305 | 305 | }); | |
| 306 | 306 | ||
@@ -432,15 +432,15 @@ check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' }); | |||
| 432 | 432 | } | |
| 433 | 433 | ||
| 434 | 434 | // Test QueryString.unescapeBuffer | |
| 435 | - qsUnescapeTestCases.forEach(function(testCase) { | ||
| 435 | + qsUnescapeTestCases.forEach((testCase) => { | ||
| 436 | 436 | assert.strictEqual(qs.unescape(testCase[0]), testCase[1]); | |
| 437 | 437 | assert.strictEqual(qs.unescapeBuffer(testCase[0]).toString(), testCase[1]); | |
| 438 | 438 | }); | |
| 439 | 439 | ||
| 440 | 440 | // test overriding .unescape | |
| 441 | 441 | { | |
| 442 | 442 | const prevUnescape = qs.unescape; | |
| 443 | - qs.unescape = function(str) { | ||
| 443 | + qs.unescape = (str) => { | ||
| 444 | 444 | return str.replace(/o/g, '_'); | |
| 445 | 445 | }; | |
| 446 | 446 | check( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,10 +41,10 @@ function test8(clazz) { | |||
| 41 | 41 | assert.strictEqual(0xfb, buffer[1]); | |
| 42 | 42 | ||
| 43 | 43 | /* Make sure we handle truncation correctly */ | |
| 44 | - assert.throws(function() { | ||
| 44 | + assert.throws(() => { | ||
| 45 | 45 | buffer.writeInt8(0xabc, 0); | |
| 46 | 46 | }, errorOutOfBounds); | |
| 47 | - assert.throws(function() { | ||
| 47 | + assert.throws(() => { | ||
| 48 | 48 | buffer.writeInt8(0xabc, 0); | |
| 49 | 49 | }, errorOutOfBounds); | |
| 50 | 50 | ||
@@ -54,10 +54,10 @@ function test8(clazz) { | |||
| 54 | 54 | ||
| 55 | 55 | assert.strictEqual(0x7f, buffer[0]); | |
| 56 | 56 | assert.strictEqual(0x80, buffer[1]); | |
| 57 | - assert.throws(function() { | ||
| 57 | + assert.throws(() => { | ||
| 58 | 58 | buffer.writeInt8(0x7f + 1, 0); | |
| 59 | 59 | }, errorOutOfBounds); | |
| 60 | - assert.throws(function() { | ||
| 60 | + assert.throws(() => { | ||
| 61 | 61 | buffer.writeInt8(-0x80 - 1, 0); | |
| 62 | 62 | }, errorOutOfBounds); | |
| 63 | 63 | } | |
@@ -94,10 +94,10 @@ function test16(clazz) { | |||
| 94 | 94 | assert.strictEqual(0xff, buffer[1]); | |
| 95 | 95 | assert.strictEqual(0x80, buffer[2]); | |
| 96 | 96 | assert.strictEqual(0x00, buffer[3]); | |
| 97 | - assert.throws(function() { | ||
| 97 | + assert.throws(() => { | ||
| 98 | 98 | buffer.writeInt16BE(0x7fff + 1, 0); | |
| 99 | 99 | }, errorOutOfBounds); | |
| 100 | - assert.throws(function() { | ||
| 100 | + assert.throws(() => { | ||
| 101 | 101 | buffer.writeInt16BE(-0x8000 - 1, 0); | |
| 102 | 102 | }, errorOutOfBounds); | |
| 103 | 103 | ||
@@ -107,10 +107,10 @@ function test16(clazz) { | |||
| 107 | 107 | assert.strictEqual(0x7f, buffer[1]); | |
| 108 | 108 | assert.strictEqual(0x00, buffer[2]); | |
| 109 | 109 | assert.strictEqual(0x80, buffer[3]); | |
| 110 | - assert.throws(function() { | ||
| 110 | + assert.throws(() => { | ||
| 111 | 111 | buffer.writeInt16LE(0x7fff + 1, 0); | |
| 112 | 112 | }, errorOutOfBounds); | |
| 113 | - assert.throws(function() { | ||
| 113 | + assert.throws(() => { | ||
| 114 | 114 | buffer.writeInt16LE(-0x8000 - 1, 0); | |
| 115 | 115 | }, errorOutOfBounds); | |
| 116 | 116 | } | |
@@ -163,10 +163,10 @@ function test32(clazz) { | |||
| 163 | 163 | assert.strictEqual(0x00, buffer[5]); | |
| 164 | 164 | assert.strictEqual(0x00, buffer[6]); | |
| 165 | 165 | assert.strictEqual(0x00, buffer[7]); | |
| 166 | - assert.throws(function() { | ||
| 166 | + assert.throws(() => { | ||
| 167 | 167 | buffer.writeInt32BE(0x7fffffff + 1, 0); | |
| 168 | 168 | }, errorOutOfBounds); | |
| 169 | - assert.throws(function() { | ||
| 169 | + assert.throws(() => { | ||
| 170 | 170 | buffer.writeInt32BE(-0x80000000 - 1, 0); | |
| 171 | 171 | }, errorOutOfBounds); | |
| 172 | 172 | ||
@@ -180,10 +180,10 @@ function test32(clazz) { | |||
| 180 | 180 | assert.strictEqual(0x00, buffer[5]); | |
| 181 | 181 | assert.strictEqual(0x00, buffer[6]); | |
| 182 | 182 | assert.strictEqual(0x80, buffer[7]); | |
| 183 | - assert.throws(function() { | ||
| 183 | + assert.throws(() => { | ||
| 184 | 184 | buffer.writeInt32LE(0x7fffffff + 1, 0); | |
| 185 | 185 | }, errorOutOfBounds); | |
| 186 | - assert.throws(function() { | ||
| 186 | + assert.throws(() => { | ||
| 187 | 187 | buffer.writeInt32LE(-0x80000000 - 1, 0); | |
| 188 | 188 | }, errorOutOfBounds); | |
| 189 | 189 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,20 +4,20 @@ | |||
| 4 | 4 | const common = require('../common'); | |
| 5 | 5 | const http = require('http'); | |
| 6 | 6 | ||
| 7 | - const server = http.createServer(function(req, res) { | ||
| 7 | + const server = http.createServer((req, res) => { | ||
| 8 | 8 | const buffer = Buffer.alloc(0); | |
| 9 | 9 | // FIXME: WTF gjslint want this? | |
| 10 | 10 | res.writeHead(200, { 'Content-Type': 'text/html', | |
| 11 | 11 | 'Content-Length': buffer.length }); | |
| 12 | 12 | res.end(buffer); | |
| 13 | 13 | }); | |
| 14 | 14 | ||
| 15 | - server.listen(0, common.mustCall(function() { | ||
| 16 | - http.get({ port: this.address().port }, common.mustCall(function(res) { | ||
| 15 | + server.listen(0, common.mustCall(() => { | ||
| 16 | + http.get({ port: server.address().port }, common.mustCall((res) => { | ||
| 17 | 17 | ||
| 18 | 18 | res.on('data', common.mustNotCall()); | |
| 19 | 19 | ||
| 20 | - res.on('end', function(d) { | ||
| 20 | + res.on('end', (d) => { | ||
| 21 | 21 | server.close(); | |
| 22 | 22 | }); | |
| 23 | 23 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments