| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | function 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 | |||||
| 17 | module.exports = allocUnsafe | ||||