3 var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
5 function highWaterMarkFrom(options, isDuplex, duplexKey) {
6 return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
9 function getHighWaterMark(state, options, duplexKey, isDuplex) {
10 var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
13 if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
14 var name = isDuplex ? duplexKey : 'highWaterMark';
15 throw new ERR_INVALID_OPT_VALUE(name, hwm);
18 return Math.floor(hwm);
22 return state.objectMode ? 16 : 16 * 1024;
26 getHighWaterMark: getHighWaterMark