Use Buffer.alloc if it is available.

This commit is contained in:
anseki 2016-04-27 22:57:16 +09:00
parent 5f5492ce0c
commit 8c78b18e58

View file

@ -361,7 +361,11 @@ function _readlineSync(options) {
input = tryExt();
return;
}
buffer = new Buffer((reqSize = options.keyIn ? 1 : options.bufferSize));
if (Buffer.alloc) {
buffer = Buffer.alloc((reqSize = options.keyIn ? 1 : options.bufferSize));
} else {
buffer = new Buffer((reqSize = options.keyIn ? 1 : options.bufferSize));
}
if (options.keyIn && options.limit) {
limit = new RegExp('[^' + options.limit + ']',