lib,test: remove yoda statements
PR-URL: https://github.com/nodejs/node/pull/18746 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
7bc8eb8da7
commit
f2d93795bf
@ -838,7 +838,7 @@ function resume_(stream, state) {
|
||||
|
||||
Readable.prototype.pause = function() {
|
||||
debug('call pause flowing=%j', this._readableState.flowing);
|
||||
if (false !== this._readableState.flowing) {
|
||||
if (this._readableState.flowing !== false) {
|
||||
debug('pause');
|
||||
this._readableState.flowing = false;
|
||||
this.emit('pause');
|
||||
|
@ -87,33 +87,33 @@ if (process.binding('config').hasIntl) {
|
||||
if (
|
||||
code >= 0x1100 && (
|
||||
code <= 0x115f || // Hangul Jamo
|
||||
0x2329 === code || // LEFT-POINTING ANGLE BRACKET
|
||||
0x232a === code || // RIGHT-POINTING ANGLE BRACKET
|
||||
code === 0x2329 || // LEFT-POINTING ANGLE BRACKET
|
||||
code === 0x232a || // RIGHT-POINTING ANGLE BRACKET
|
||||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
||||
(0x2e80 <= code && code <= 0x3247 && code !== 0x303f) ||
|
||||
code >= 0x2e80 && code <= 0x3247 && code !== 0x303f ||
|
||||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
||||
0x3250 <= code && code <= 0x4dbf ||
|
||||
code >= 0x3250 && code <= 0x4dbf ||
|
||||
// CJK Unified Ideographs .. Yi Radicals
|
||||
0x4e00 <= code && code <= 0xa4c6 ||
|
||||
code >= 0x4e00 && code <= 0xa4c6 ||
|
||||
// Hangul Jamo Extended-A
|
||||
0xa960 <= code && code <= 0xa97c ||
|
||||
code >= 0xa960 && code <= 0xa97c ||
|
||||
// Hangul Syllables
|
||||
0xac00 <= code && code <= 0xd7a3 ||
|
||||
code >= 0xac00 && code <= 0xd7a3 ||
|
||||
// CJK Compatibility Ideographs
|
||||
0xf900 <= code && code <= 0xfaff ||
|
||||
code >= 0xf900 && code <= 0xfaff ||
|
||||
// Vertical Forms
|
||||
0xfe10 <= code && code <= 0xfe19 ||
|
||||
code >= 0xfe10 && code <= 0xfe19 ||
|
||||
// CJK Compatibility Forms .. Small Form Variants
|
||||
0xfe30 <= code && code <= 0xfe6b ||
|
||||
code >= 0xfe30 && code <= 0xfe6b ||
|
||||
// Halfwidth and Fullwidth Forms
|
||||
0xff01 <= code && code <= 0xff60 ||
|
||||
0xffe0 <= code && code <= 0xffe6 ||
|
||||
code >= 0xff01 && code <= 0xff60 ||
|
||||
code >= 0xffe0 && code <= 0xffe6 ||
|
||||
// Kana Supplement
|
||||
0x1b000 <= code && code <= 0x1b001 ||
|
||||
code >= 0x1b000 && code <= 0x1b001 ||
|
||||
// Enclosed Ideographic Supplement
|
||||
0x1f200 <= code && code <= 0x1f251 ||
|
||||
code >= 0x1f200 && code <= 0x1f251 ||
|
||||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
||||
0x20000 <= code && code <= 0x3fffd
|
||||
code >= 0x20000 && code <= 0x3fffd
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
|
@ -12,10 +12,8 @@ Stream.prototype.pipe = function(dest, options) {
|
||||
var source = this;
|
||||
|
||||
function ondata(chunk) {
|
||||
if (dest.writable) {
|
||||
if (false === dest.write(chunk) && source.pause) {
|
||||
source.pause();
|
||||
}
|
||||
if (dest.writable && dest.write(chunk) === false && source.pause) {
|
||||
source.pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ class InspectorSession {
|
||||
}
|
||||
|
||||
_isBreakOnLineNotification(message, line, expectedScriptPath) {
|
||||
if ('Debugger.paused' === message.method) {
|
||||
if (message.method === 'Debugger.paused') {
|
||||
const callFrame = message.params.callFrames[0];
|
||||
const location = callFrame.location;
|
||||
const scriptPath = this._scriptsIdsByUrl.get(location.scriptId);
|
||||
@ -264,7 +264,7 @@ class InspectorSession {
|
||||
_matchesConsoleOutputNotification(notification, type, values) {
|
||||
if (!Array.isArray(values))
|
||||
values = [ values ];
|
||||
if ('Runtime.consoleAPICalled' === notification.method) {
|
||||
if (notification.method === 'Runtime.consoleAPICalled') {
|
||||
const params = notification.params;
|
||||
if (params.type === type) {
|
||||
let i = 0;
|
||||
|
@ -31,7 +31,7 @@ for (const { socket, reply } of servers) {
|
||||
}));
|
||||
|
||||
socket.bind(0, common.mustCall(() => {
|
||||
if (0 === --waiting) ready();
|
||||
if (--waiting === 0) ready();
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ const watcher = fs.watch(testDir, { recursive: true });
|
||||
|
||||
let watcherClosed = false;
|
||||
watcher.on('change', function(event, filename) {
|
||||
assert.ok('change' === event || 'rename' === event);
|
||||
assert.ok(event === 'change' || event === 'rename');
|
||||
|
||||
// Ignore stale events generated by mkdir and other tests
|
||||
if (filename !== relativePathOne)
|
||||
|
@ -53,7 +53,7 @@ function pingPongTest(port, host) {
|
||||
// Since we never queue data (we're always waiting for the PING
|
||||
// before sending a pong) the writeQueueSize should always be less
|
||||
// than one message.
|
||||
assert.ok(0 <= socket.bufferSize && socket.bufferSize <= 4);
|
||||
assert.ok(socket.bufferSize >= 0 && socket.bufferSize <= 4);
|
||||
|
||||
assert.strictEqual(socket.writable, true);
|
||||
assert.strictEqual(socket.readable, true);
|
||||
|
@ -88,7 +88,7 @@ function makeConnection(index) {
|
||||
|
||||
c.on('data', function(b) {
|
||||
gotData = true;
|
||||
assert.ok(0 < b.length);
|
||||
assert.ok(b.length > 0);
|
||||
});
|
||||
|
||||
c.on('error', function(e) {
|
||||
|
@ -60,7 +60,7 @@ server.listen(0, common.mustCall(() => {
|
||||
console.error('sending');
|
||||
const ret = client.write(Buffer.allocUnsafe(bufSize));
|
||||
console.error(`write => ${ret}`);
|
||||
if (false !== ret) {
|
||||
if (ret !== false) {
|
||||
console.error('write again');
|
||||
sent += bufSize;
|
||||
assert.ok(sent < 100 * 1024 * 1024); // max 100MB
|
||||
|
@ -39,7 +39,7 @@ const server = net.createServer(function(connection) {
|
||||
connection.write(body.slice(part_N, 2 * part_N));
|
||||
assert.strictEqual(false, connection.write(body.slice(2 * part_N, N)));
|
||||
console.log(`bufferSize: ${connection.bufferSize}`, 'expecting', N);
|
||||
assert.ok(0 <= connection.bufferSize &&
|
||||
assert.ok(connection.bufferSize >= 0 &&
|
||||
connection.writableLength <= N);
|
||||
connection.end();
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ let complete = 0;
|
||||
// FATAL ERROR: JS Allocation failed - process out of memory
|
||||
// if the depth counter doesn't clear the nextTickQueue properly.
|
||||
(function runner() {
|
||||
if (1e8 > ++complete)
|
||||
if (++complete < 1e8)
|
||||
process.nextTick(runner);
|
||||
}());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user