| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3ecc964 commit 362f5ed
26 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -175,6 +175,7 @@ module.exports = { | |||
| 175 | 175 | }], | |
| 176 | 176 | 'new-parens': 'error', | |
| 177 | 177 | 'no-async-promise-executor': 'error', | |
| 178 | + 'no-case-declarations': 'error', | ||
| 178 | 179 | 'no-class-assign': 'error', | |
| 179 | 180 | 'no-confusing-arrow': 'error', | |
| 180 | 181 | 'no-const-assign': 'error', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ function main({ n, method, inputLen }) { | |||
| 16 | 16 | let i = 0; | |
| 17 | 17 | switch (method) { | |
| 18 | 18 | // Performs `n` single inflate operations | |
| 19 | - case 'inflate': | ||
| 19 | + case 'inflate': { | ||
| 20 | 20 | const inflate = zlib.inflate; | |
| 21 | 21 | bench.start(); | |
| 22 | 22 | (function next(err, result) { | |
@@ -25,14 +25,16 @@ function main({ n, method, inputLen }) { | |||
| 25 | 25 | inflate(chunk, next); | |
| 26 | 26 | })(); | |
| 27 | 27 | break; | |
| 28 | + } | ||
| 28 | 29 | // Performs `n` single inflateSync operations | |
| 29 | - case 'inflateSync': | ||
| 30 | + case 'inflateSync': { | ||
| 30 | 31 | const inflateSync = zlib.inflateSync; | |
| 31 | 32 | bench.start(); | |
| 32 | 33 | for (; i < n; ++i) | |
| 33 | 34 | inflateSync(chunk); | |
| 34 | 35 | bench.end(n); | |
| 35 | 36 | break; | |
| 37 | + } | ||
| 36 | 38 | default: | |
| 37 | 39 | throw new Error('Unsupported inflate method'); | |
| 38 | 40 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -413,7 +413,7 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) { | |||
| 413 | 413 | ||
| 414 | 414 | Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) { | |
| 415 | 415 | switch (event) { | |
| 416 | - case 'request': | ||
| 416 | + case 'request': { | ||
| 417 | 417 | const { 1: res } = args; | |
| 418 | 418 | if (!res.headersSent && !res.writableEnded) { | |
| 419 | 419 | // Don't leak headers. | |
@@ -427,6 +427,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) { | |||
| 427 | 427 | res.destroy(); | |
| 428 | 428 | } | |
| 429 | 429 | break; | |
| 430 | + } | ||
| 430 | 431 | default: | |
| 431 | 432 | net.Server.prototype[SymbolFor('nodejs.rejection')] | |
| 432 | 433 | .apply(this, arguments); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,20 +42,22 @@ function createWritableStdioStream(fd) { | |||
| 42 | 42 | let stream; | |
| 43 | 43 | // Note stream._type is used for test-module-load-list.js | |
| 44 | 44 | switch (guessHandleType(fd)) { | |
| 45 | - case 'TTY': | ||
| 45 | + case 'TTY': { | ||
| 46 | 46 | const tty = require('tty'); | |
| 47 | 47 | stream = new tty.WriteStream(fd); | |
| 48 | 48 | stream._type = 'tty'; | |
| 49 | 49 | break; | |
| 50 | + } | ||
| 50 | 51 | ||
| 51 | - case 'FILE': | ||
| 52 | + case 'FILE': { | ||
| 52 | 53 | const SyncWriteStream = require('internal/fs/sync_write_stream'); | |
| 53 | 54 | stream = new SyncWriteStream(fd, { autoClose: false }); | |
| 54 | 55 | stream._type = 'fs'; | |
| 55 | 56 | break; | |
| 57 | + } | ||
| 56 | 58 | ||
| 57 | 59 | case 'PIPE': | |
| 58 | - case 'TCP': | ||
| 60 | + case 'TCP': { | ||
| 59 | 61 | const net = require('net'); | |
| 60 | 62 | ||
| 61 | 63 | // If fd is already being used for the IPC channel, libuv will return | |
@@ -78,8 +80,9 @@ function createWritableStdioStream(fd) { | |||
| 78 | 80 | ||
| 79 | 81 | stream._type = 'pipe'; | |
| 80 | 82 | break; | |
| 83 | + } | ||
| 81 | 84 | ||
| 82 | - default: | ||
| 85 | + default: { | ||
| 83 | 86 | // Provide a dummy black-hole output for e.g. non-console | |
| 84 | 87 | // Windows applications. | |
| 85 | 88 | const { Writable } = require('stream'); | |
@@ -88,6 +91,7 @@ function createWritableStdioStream(fd) { | |||
| 88 | 91 | cb(); | |
| 89 | 92 | } | |
| 90 | 93 | }); | |
| 94 | + } | ||
| 91 | 95 | } | |
| 92 | 96 | ||
| 93 | 97 | // For supporting legacy API we put the FD here. | |
@@ -147,22 +151,24 @@ function getStdin() { | |||
| 147 | 151 | const fd = 0; | |
| 148 | 152 | ||
| 149 | 153 | switch (guessHandleType(fd)) { | |
| 150 | - case 'TTY': | ||
| 154 | + case 'TTY': { | ||
| 151 | 155 | const tty = require('tty'); | |
| 152 | 156 | stdin = new tty.ReadStream(fd, { | |
| 153 | 157 | highWaterMark: 0, | |
| 154 | 158 | readable: true, | |
| 155 | 159 | writable: false | |
| 156 | 160 | }); | |
| 157 | 161 | break; | |
| 162 | + } | ||
| 158 | 163 | ||
| 159 | - case 'FILE': | ||
| 164 | + case 'FILE': { | ||
| 160 | 165 | const fs = require('fs'); | |
| 161 | 166 | stdin = new fs.ReadStream(null, { fd: fd, autoClose: false }); | |
| 162 | 167 | break; | |
| 168 | + } | ||
| 163 | 169 | ||
| 164 | 170 | case 'PIPE': | |
| 165 | - case 'TCP': | ||
| 171 | + case 'TCP': { | ||
| 166 | 172 | const net = require('net'); | |
| 167 | 173 | ||
| 168 | 174 | // It could be that process has been started with an IPC channel | |
@@ -187,13 +193,15 @@ function getStdin() { | |||
| 187 | 193 | // Make sure the stdin can't be `.end()`-ed | |
| 188 | 194 | stdin._writableState.ended = true; | |
| 189 | 195 | break; | |
| 196 | + } | ||
| 190 | 197 | ||
| 191 | - default: | ||
| 198 | + default: { | ||
| 192 | 199 | // Provide a dummy contentless input for e.g. non-console | |
| 193 | 200 | // Windows applications. | |
| 194 | 201 | const { Readable } = require('stream'); | |
| 195 | 202 | stdin = new Readable({ read() {} }); | |
| 196 | 203 | stdin.push(null); | |
| 204 | + } | ||
| 197 | 205 | } | |
| 198 | 206 | ||
| 199 | 207 | // For supporting legacy API we put the FD here. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,7 +189,7 @@ function asyncAesGcmCipher( | |||
| 189 | 189 | const tagByteLength = MathFloor(tagLength / 8); | |
| 190 | 190 | let tag; | |
| 191 | 191 | switch (mode) { | |
| 192 | - case kWebCryptoCipherDecrypt: | ||
| 192 | + case kWebCryptoCipherDecrypt: { | ||
| 193 | 193 | const slice = ArrayBufferIsView(data) ? | |
| 194 | 194 | TypedArrayPrototypeSlice : ArrayBufferPrototypeSlice; | |
| 195 | 195 | tag = slice(data, -tagByteLength); | |
@@ -206,6 +206,7 @@ function asyncAesGcmCipher( | |||
| 206 | 206 | ||
| 207 | 207 | data = slice(data, 0, -tagByteLength); | |
| 208 | 208 | break; | |
| 209 | + } | ||
| 209 | 210 | case kWebCryptoCipherEncrypt: | |
| 210 | 211 | tag = tagByteLength; | |
| 211 | 212 | break; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -427,7 +427,7 @@ async function importGenericSecretKey( | |||
| 427 | 427 | ||
| 428 | 428 | break; | |
| 429 | 429 | } | |
| 430 | - case 'raw': | ||
| 430 | + case 'raw': { | ||
| 431 | 431 | if (hasAnyNotIn(usagesSet, ['deriveKey', 'deriveBits'])) { | |
| 432 | 432 | throw lazyDOMException( | |
| 433 | 433 | `Unsupported key usage for a ${name} key`, | |
@@ -449,6 +449,7 @@ async function importGenericSecretKey( | |||
| 449 | 449 | ||
| 450 | 450 | const keyObject = createSecretKey(keyData); | |
| 451 | 451 | return new InternalCryptoKey(keyObject, { name }, keyUsages, false); | |
| 452 | + } | ||
| 452 | 453 | } | |
| 453 | 454 | ||
| 454 | 455 | throw lazyDOMException( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,21 +120,23 @@ let deserialize; | |||
| 120 | 120 | function deserializeError(error) { | |
| 121 | 121 | if (!deserialize) deserialize = require('v8').deserialize; | |
| 122 | 122 | switch (error[0]) { | |
| 123 | - case kSerializedError: | ||
| 123 | + case kSerializedError: { | ||
| 124 | 124 | const { constructor, properties } = deserialize(error.subarray(1)); | |
| 125 | 125 | const ctor = errors[constructor]; | |
| 126 | 126 | ObjectDefineProperty(properties, SymbolToStringTag, { | |
| 127 | 127 | value: { value: 'Error', configurable: true }, | |
| 128 | 128 | enumerable: true | |
| 129 | 129 | }); | |
| 130 | 130 | return ObjectCreate(ctor.prototype, properties); | |
| 131 | + } | ||
| 131 | 132 | case kSerializedObject: | |
| 132 | 133 | return deserialize(error.subarray(1)); | |
| 133 | - case kInspectedError: | ||
| 134 | + case kInspectedError: { | ||
| 134 | 135 | const buf = Buffer.from(error.buffer, | |
| 135 | 136 | error.byteOffset + 1, | |
| 136 | 137 | error.byteLength - 1); | |
| 137 | 138 | return buf.toString('utf8'); | |
| 139 | + } | ||
| 138 | 140 | } | |
| 139 | 141 | require('assert').fail('This should not happen'); | |
| 140 | 142 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,28 +217,31 @@ const proxySocketHandler = { | |||
| 217 | 217 | case 'writable': | |
| 218 | 218 | case 'destroyed': | |
| 219 | 219 | return stream[prop]; | |
| 220 | - case 'readable': | ||
| 220 | + case 'readable': { | ||
| 221 | 221 | if (stream.destroyed) | |
| 222 | 222 | return false; | |
| 223 | 223 | const request = stream[kRequest]; | |
| 224 | 224 | return request ? request.readable : stream.readable; | |
| 225 | - case 'setTimeout': | ||
| 225 | + } | ||
| 226 | + case 'setTimeout': { | ||
| 226 | 227 | const session = stream.session; | |
| 227 | 228 | if (session !== undefined) | |
| 228 | 229 | return FunctionPrototypeBind(session.setTimeout, session); | |
| 229 | 230 | return FunctionPrototypeBind(stream.setTimeout, stream); | |
| 231 | + } | ||
| 230 | 232 | case 'write': | |
| 231 | 233 | case 'read': | |
| 232 | 234 | case 'pause': | |
| 233 | 235 | case 'resume': | |
| 234 | 236 | throw new ERR_HTTP2_NO_SOCKET_MANIPULATION(); | |
| 235 | - default: | ||
| 237 | + default: { | ||
| 236 | 238 | const ref = stream.session !== undefined ? | |
| 237 | 239 | stream.session[kSocket] : stream; | |
| 238 | 240 | const value = ref[prop]; | |
| 239 | 241 | return typeof value === 'function' ? | |
| 240 | 242 | FunctionPrototypeBind(value, ref) : | |
| 241 | 243 | value; | |
| 244 | + } | ||
| 242 | 245 | } | |
| 243 | 246 | }, | |
| 244 | 247 | getPrototypeOf(stream) { | |
@@ -258,23 +261,25 @@ const proxySocketHandler = { | |||
| 258 | 261 | case 'destroy': | |
| 259 | 262 | stream[prop] = value; | |
| 260 | 263 | return true; | |
| 261 | - case 'setTimeout': | ||
| 264 | + case 'setTimeout': { | ||
| 262 | 265 | const session = stream.session; | |
| 263 | 266 | if (session !== undefined) | |
| 264 | 267 | session.setTimeout = value; | |
| 265 | 268 | else | |
| 266 | 269 | stream.setTimeout = value; | |
| 267 | 270 | return true; | |
| 271 | + } | ||
| 268 | 272 | case 'write': | |
| 269 | 273 | case 'read': | |
| 270 | 274 | case 'pause': | |
| 271 | 275 | case 'resume': | |
| 272 | 276 | throw new ERR_HTTP2_NO_SOCKET_MANIPULATION(); | |
| 273 | - default: | ||
| 277 | + default: { | ||
| 274 | 278 | const ref = stream.session !== undefined ? | |
| 275 | 279 | stream.session[kSocket] : stream; | |
| 276 | 280 | ref[prop] = value; | |
| 277 | 281 | return true; | |
| 282 | + } | ||
| 278 | 283 | } | |
| 279 | 284 | } | |
| 280 | 285 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -862,14 +862,15 @@ const proxySocketHandler = { | |||
| 862 | 862 | case 'setKeepAlive': | |
| 863 | 863 | case 'setNoDelay': | |
| 864 | 864 | throw new ERR_HTTP2_NO_SOCKET_MANIPULATION(); | |
| 865 | - default: | ||
| 865 | + default: { | ||
| 866 | 866 | const socket = session[kSocket]; | |
| 867 | 867 | if (socket === undefined) | |
| 868 | 868 | throw new ERR_HTTP2_SOCKET_UNBOUND(); | |
| 869 | 869 | const value = socket[prop]; | |
| 870 | 870 | return typeof value === 'function' ? | |
| 871 | 871 | FunctionPrototypeBind(value, socket) : | |
| 872 | 872 | value; | |
| 873 | + } | ||
| 873 | 874 | } | |
| 874 | 875 | }, | |
| 875 | 876 | getPrototypeOf(session) { | |
@@ -896,12 +897,13 @@ const proxySocketHandler = { | |||
| 896 | 897 | case 'setKeepAlive': | |
| 897 | 898 | case 'setNoDelay': | |
| 898 | 899 | throw new ERR_HTTP2_NO_SOCKET_MANIPULATION(); | |
| 899 | - default: | ||
| 900 | + default: { | ||
| 900 | 901 | const socket = session[kSocket]; | |
| 901 | 902 | if (socket === undefined) | |
| 902 | 903 | throw new ERR_HTTP2_SOCKET_UNBOUND(); | |
| 903 | 904 | socket[prop] = value; | |
| 904 | 905 | return true; | |
| 906 | + } | ||
| 905 | 907 | } | |
| 906 | 908 | } | |
| 907 | 909 | }; | |
@@ -1553,10 +1555,11 @@ class Http2Session extends EventEmitter { | |||
| 1553 | 1555 | ||
| 1554 | 1556 | [EventEmitter.captureRejectionSymbol](err, event, ...args) { | |
| 1555 | 1557 | switch (event) { | |
| 1556 | - case 'stream': | ||
| 1558 | + case 'stream': { | ||
| 1557 | 1559 | const stream = args[0]; | |
| 1558 | 1560 | stream.destroy(err); | |
| 1559 | 1561 | break; | |
| 1562 | + } | ||
| 1560 | 1563 | default: | |
| 1561 | 1564 | this.destroy(err); | |
| 1562 | 1565 | } | |
@@ -3176,7 +3179,7 @@ Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function( | |||
| 3176 | 3179 | err, event, ...args) { | |
| 3177 | 3180 | ||
| 3178 | 3181 | switch (event) { | |
| 3179 | - case 'stream': | ||
| 3182 | + case 'stream': { | ||
| 3180 | 3183 | // TODO(mcollina): we might want to match this with what we do on | |
| 3181 | 3184 | // the compat side. | |
| 3182 | 3185 | const { 0: stream } = args; | |
@@ -3187,7 +3190,8 @@ Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function( | |||
| 3187 | 3190 | stream.end(); | |
| 3188 | 3191 | } | |
| 3189 | 3192 | break; | |
| 3190 | - case 'request': | ||
| 3193 | + } | ||
| 3194 | + case 'request': { | ||
| 3191 | 3195 | const { 1: res } = args; | |
| 3192 | 3196 | if (!res.headersSent && !res.finished) { | |
| 3193 | 3197 | // Don't leak headers. | |
@@ -3200,6 +3204,7 @@ Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function( | |||
| 3200 | 3204 | res.destroy(); | |
| 3201 | 3205 | } | |
| 3202 | 3206 | break; | |
| 3207 | + } | ||
| 3203 | 3208 | default: | |
| 3204 | 3209 | ArrayPrototypeUnshift(args, err, event); | |
| 3205 | 3210 | ReflectApply(net.Server.prototype[EventEmitter.captureRejectionSymbol], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,14 +110,15 @@ function isRecoverableError(e, code) { | |||
| 110 | 110 | recoverable = true; | |
| 111 | 111 | break; | |
| 112 | 112 | ||
| 113 | - case 'Unterminated string constant': | ||
| 113 | + case 'Unterminated string constant': { | ||
| 114 | 114 | const token = StringPrototypeSlice(this.input, | |
| 115 | 115 | this.lastTokStart, this.pos); | |
| 116 | 116 | // See https://www.ecma-international.org/ecma-262/#sec-line-terminators | |
| 117 | 117 | if (RegExpPrototypeTest(/\\(?:\r\n?|\n|\u2028|\u2029)$/, | |
| 118 | 118 | token)) { | |
| 119 | 119 | recoverable = true; | |
| 120 | 120 | } | |
| 121 | + } | ||
| 121 | 122 | } | |
| 122 | 123 | super.raise(pos, message); | |
| 123 | 124 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments