2
0
mirror of https://github.com/cderche/greenlock-storage-s3 synced 2025-12-24 13:28:38 +00:00
2019-05-08 12:19:12 +01:00

22 lines
519 B
JavaScript

var Buffer = require('../core').util.Buffer;
/**
* Allocates a buffer.
* @param {number} size Number of bytes to allocate for the buffer.
* @returns {Buffer}
*/
function allocBuffer(size) {
if (typeof size !== 'number') {
throw new Error('size passed to allocBuffer must be a number.');
}
var buffer = typeof Buffer.alloc === 'function' ? Buffer.alloc(size) : new Buffer(size);
buffer.fill(0);
return buffer;
}
/**
* @api private
*/
module.exports = {
allocBuffer: allocBuffer
};