Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
749 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
|
---|
4 |
|
---|
5 | function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
---|
6 | return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
---|
7 | }
|
---|
8 |
|
---|
9 | function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
---|
10 | var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
---|
11 |
|
---|
12 | if (hwm != null) {
|
---|
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);
|
---|
16 | }
|
---|
17 |
|
---|
18 | return Math.floor(hwm);
|
---|
19 | } // Default value
|
---|
20 |
|
---|
21 |
|
---|
22 | return state.objectMode ? 16 : 16 * 1024;
|
---|
23 | }
|
---|
24 |
|
---|
25 | module.exports = {
|
---|
26 | getHighWaterMark: getHighWaterMark
|
---|
27 | }; |
---|
Note:
See
TracBrowser
for help on using the repository browser.