blob: 0bd335ffdd319bd4e9d0d40d9e1de61873dbd57c [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001function allocUnsafe (size) {
2 if (typeof size !== 'number') {
3 throw new TypeError('"size" argument must be a number')
4 }
5
6 if (size < 0) {
7 throw new RangeError('"size" argument must not be negative')
8 }
9
10 if (Buffer.allocUnsafe) {
11 return Buffer.allocUnsafe(size)
12 } else {
13 return new Buffer(size)
14 }
15}
16
17module.exports = allocUnsafe