1 var bufferFill = require('buffer-fill')
2 var allocUnsafe = require('buffer-alloc-unsafe')
4 module.exports = function alloc (size, fill, encoding) {
5 if (typeof size !== 'number') {
6 throw new TypeError('"size" argument must be a number')
10 throw new RangeError('"size" argument must not be negative')
14 return Buffer.alloc(size, fill, encoding)
17 var buffer = allocUnsafe(size)
23 if (fill === undefined) {
24 return bufferFill(buffer, 0)
27 if (typeof encoding !== 'string') {
31 return bufferFill(buffer, fill, encoding)