index.js 356 B

1234567891011121314151617
  1. function allocUnsafe (size) {
  2. if (typeof size !== 'number') {
  3. throw new TypeError('"size" argument must be a number')
  4. }
  5. if (size < 0) {
  6. throw new RangeError('"size" argument must not be negative')
  7. }
  8. if (Buffer.allocUnsafe) {
  9. return Buffer.allocUnsafe(size)
  10. } else {
  11. return new Buffer(size)
  12. }
  13. }
  14. module.exports = allocUnsafe