1
0
mirror of https://github.com/advplyr/audiobookshelf.git synced 2025-08-16 01:57:48 +02:00
Files
.devcontainer
.github
.vscode
build
client
images
server
controllers
controllers2
db
finders
libs
archiver
archiverUtils
balancedMatch
braceExpansion
fsRealpath
glob
inflight
lazystream
lodash.difference
lodash.flatten
lodash.isplainobject
lodash.union
minimatch
readableStream
safeBuffer
LICENSE
index.js
stringDecoder
wrappy
file.js
index.js
buffer-crc32
compress-commons
crc32
crc32-stream
lib
normalize-path
readdir-glob
zip-stream
LICENSE
index.js
async
bcryptjs
busboy
commandLineArgs
css
dateAndTime
expressFileupload
expressRateLimit
fastSort
fluentFfmpeg
fsExtra
imageType
isexe
jsonwebtoken
jwa
jws
lodash.once
ms
nodeCron
nodeFfprobe
nodeStreamZip
readChunk
recursiveReaddirAsync
requestIp
rss
sanitizeHtml
streamsearch
uaParser
universalify
watcher
which
xml
managers
models
objects
providers
routers
routes
scanner
utils
Auth.js
Database.js
Logger.js
Server.js
SocketAuthority.js
Watcher.js
.dockerignore
.gitattributes
.gitignore
Dockerfile
LICENSE
docker-compose.yml
docker-template.xml
index.js
package-lock.json
package.json
prod.js
readme.md
audiobookshelf/server/libs/archiver/archiverUtils/safeBuffer/index.js
2022-07-08 18:11:09 -05:00

65 lines
1.6 KiB
JavaScript

/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/* eslint-disable node/no-deprecated-api, no-var */
var buffer = require('buffer')
var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers
function copyProps(src, dst) {
for (var key in src) {
dst[key] = src[key]
}
}
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer
} else {
// Copy properties from require('buffer')
copyProps(buffer, exports)
exports.Buffer = SafeBuffer
}
function SafeBuffer(arg, encodingOrOffset, length) {
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.prototype = Object.create(Buffer.prototype)
// Copy static methods from Buffer
copyProps(Buffer, SafeBuffer)
SafeBuffer.from = function (arg, encodingOrOffset, length) {
if (typeof arg === 'number') {
throw new TypeError('Argument must not be a number')
}
return Buffer(arg, encodingOrOffset, length)
}
SafeBuffer.alloc = function (size, fill, encoding) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
var buf = Buffer(size)
if (fill !== undefined) {
if (typeof encoding === 'string') {
buf.fill(fill, encoding)
} else {
buf.fill(fill)
}
} else {
buf.fill(0)
}
return buf
}
SafeBuffer.allocUnsafe = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return Buffer(size)
}
SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return buffer.SlowBuffer(size)
}