mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 09:14:40 +02:00
Remove archiver-utils dependency
This commit is contained in:
parent
bca2cfda13
commit
3c5bf376b5
86 changed files with 17236 additions and 210 deletions
|
@ -0,0 +1,33 @@
|
|||
'use strict'
|
||||
|
||||
const { MathFloor, NumberIsInteger } = require('../../ours/primordials')
|
||||
|
||||
const { ERR_INVALID_ARG_VALUE } = require('../../ours/errors').codes
|
||||
|
||||
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
||||
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null
|
||||
}
|
||||
|
||||
function getDefaultHighWaterMark(objectMode) {
|
||||
return objectMode ? 16 : 16 * 1024
|
||||
}
|
||||
|
||||
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
||||
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey)
|
||||
|
||||
if (hwm != null) {
|
||||
if (!NumberIsInteger(hwm) || hwm < 0) {
|
||||
const name = isDuplex ? `options.${duplexKey}` : 'options.highWaterMark'
|
||||
throw new ERR_INVALID_ARG_VALUE(name, hwm)
|
||||
}
|
||||
|
||||
return MathFloor(hwm)
|
||||
} // Default value
|
||||
|
||||
return getDefaultHighWaterMark(state.objectMode)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getHighWaterMark,
|
||||
getDefaultHighWaterMark
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue