Skip to content

Commit

Permalink
events: rename high & low watermark for consistency
Browse files Browse the repository at this point in the history
PR-URL: #52080
Fixes: #52078
Refs: #41276
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
atlowChemi authored and marco-ippolito committed May 3, 2024
1 parent 7e35a16 commit 7bfb0b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lib/events.js
Expand Up @@ -1051,8 +1051,8 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
* @param {{
* signal: AbortSignal;
* close?: string[];
* highWatermark?: number,
* lowWatermark?: number
* highWaterMark?: number,
* lowWaterMark?: number
* }} [options]
* @returns {AsyncIterator}
*/
Expand All @@ -1062,10 +1062,12 @@ function on(emitter, event, options = kEmptyObject) {
validateAbortSignal(signal, 'options.signal');
if (signal?.aborted)
throw new AbortError(undefined, { cause: signal?.reason });
const highWatermark = options.highWatermark ?? NumberMAX_SAFE_INTEGER;
validateInteger(highWatermark, 'options.highWatermark', 1);
const lowWatermark = options.lowWatermark ?? 1;
validateInteger(lowWatermark, 'options.lowWatermark', 1);
// Support both highWaterMark and highWatermark for backward compatibility
const highWatermark = options.highWaterMark ?? options.highWatermark ?? NumberMAX_SAFE_INTEGER;
validateInteger(highWatermark, 'options.highWaterMark', 1);
// Support both lowWaterMark and lowWatermark for backward compatibility
const lowWatermark = options.lowWaterMark ?? options.lowWatermark ?? 1;
validateInteger(lowWatermark, 'options.lowWaterMark', 1);

// Preparing controlling queues and variables
FixedQueue ??= require('internal/fixed_queue');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/readline/interface.js
Expand Up @@ -1359,7 +1359,7 @@ class Interface extends InterfaceConstructor {
this[kLineObjectStream] = EventEmitter.on(
this, 'line', {
close: ['close'],
highWatermark: 1024,
highWaterMark: 1024,
[kFirstEventParam]: true,
});
}
Expand Down

0 comments on commit 7bfb0b4

Please sign in to comment.