mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2024-11-25 03:36:08 -07:00
15 lines
423 B
JavaScript
15 lines
423 B
JavaScript
|
module.exports = toBuffer
|
||
|
|
||
|
var makeBuffer = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from : bufferFrom
|
||
|
|
||
|
function bufferFrom (buf, enc) {
|
||
|
return new Buffer(buf, enc)
|
||
|
}
|
||
|
|
||
|
function toBuffer (buf, enc) {
|
||
|
if (Buffer.isBuffer(buf)) return buf
|
||
|
if (typeof buf === 'string') return makeBuffer(buf, enc)
|
||
|
if (Array.isArray(buf)) return makeBuffer(buf)
|
||
|
throw new Error('Input should be a buffer or a string')
|
||
|
}
|