gl-store-s3.js/node_modules/aws-sdk/lib/event-stream/alloc-buffer.js

22 lines
519 B
JavaScript
Raw Normal View History

2019-05-08 11:19:12 +00:00
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
};