.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / readable-stream / lib / internal / streams / state.js
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 };