Skip to content

Commit eb98d9d

Browse files
authored
use Buffer.alloc if available
1 parent 10dd2f8 commit eb98d9d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module.exports = function alloc (size, fill, encoding) {
99
if (size < 0) {
1010
throw new RangeError('"size" argument must not be negative')
1111
}
12+
13+
if (Buffer.alloc) {
14+
return Buffer.alloc(size, fill, encoding)
15+
}
1216

1317
var buffer = allocUnsafe(size)
1418

0 commit comments

Comments
 (0)