node/test/parallel/test-stream-set-default-hwm.js
Robert Nagy e7b5c0ed47
stream: add setter & getter for default highWaterMark (#46929)
Adds stream.(get|set)DefaultHighWaterMark to read or update
the default hwm.

PR-URL: https://github.com/nodejs/node/pull/46929
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
2023-03-29 20:02:10 +02:00

37 lines
877 B
JavaScript

'use strict';
require('../common');
const assert = require('node:assert');
const {
setDefaultHighWaterMark,
getDefaultHighWaterMark,
Writable,
Readable,
Transform
} = require('stream');
assert.notStrictEqual(getDefaultHighWaterMark(false), 32 * 1000);
setDefaultHighWaterMark(false, 32 * 1000);
assert.strictEqual(getDefaultHighWaterMark(false), 32 * 1000);
assert.notStrictEqual(getDefaultHighWaterMark(true), 32);
setDefaultHighWaterMark(true, 32);
assert.strictEqual(getDefaultHighWaterMark(true), 32);
const w = new Writable({
write() {}
});
assert.strictEqual(w.writableHighWaterMark, 32 * 1000);
const r = new Readable({
read() {}
});
assert.strictEqual(r.readableHighWaterMark, 32 * 1000);
const t = new Transform({
transform() {}
});
assert.strictEqual(t.writableHighWaterMark, 32 * 1000);
assert.strictEqual(t.readableHighWaterMark, 32 * 1000);