Change: option name bufSize -> bufferSize

This commit is contained in:
anseki 2015-04-05 15:39:16 +09:00
parent 44e52148dd
commit de4f2b2ffd

View file

@ -27,8 +27,8 @@ var
caseSensitive: false, caseSensitive: false,
noTrim: false, noTrim: false,
encoding: 'utf8', encoding: 'utf8',
bufSize: 1024, bufferSize: 1024,
print: null print: void 0
}, },
useExt = false, useExt = false,
@ -43,7 +43,7 @@ var
limit: string (pattern) limit: string (pattern)
caseSensitive: boolean caseSensitive: boolean
noTrim: boolean noTrim: boolean
encoding, bufSize, print encoding, bufferSize, print
*/ */
function _readlineSync(options) { function _readlineSync(options) {
var input = '', displaySave = (options.display += ''), var input = '', displaySave = (options.display += ''),
@ -147,7 +147,7 @@ function _readlineSync(options) {
input = tryExt(); input = tryExt();
return; return;
} }
buffer = new Buffer((reqSize = options.keyIn ? 1 : options.bufSize)); buffer = new Buffer((reqSize = options.keyIn ? 1 : options.bufferSize));
if (options.keyIn && options.limit) { if (options.keyIn && options.limit) {
limit = new RegExp('[^' + options.limit + ']', limit = new RegExp('[^' + options.limit + ']',
@ -421,7 +421,7 @@ function margeOptions() {
/* jshint eqnull:false */ /* jshint eqnull:false */
break; break;
// number // number
case 'bufSize': // * * case 'bufferSize': // * *
if (!isNaN(value = parseInt(value, 10)) && typeof value === 'number') if (!isNaN(value = parseInt(value, 10)) && typeof value === 'number')
{ options[optionName] = value; } { options[optionName] = value; }
break; break;
@ -434,7 +434,7 @@ function margeOptions() {
break; break;
// function // function
case 'print': // * * case 'print': // * *
options[optionName] = typeof value === 'function' ? value : null; options[optionName] = typeof value === 'function' ? value : void 0;
break; break;
// other // other
case 'prompt': // * case 'prompt': // *
@ -497,9 +497,14 @@ exports.setDefault = function(options) {
return margeOptions(true); // copy return margeOptions(true); // copy
}; };
// These APIs are now obsolete. // ======== These APIs are now obsolete. ========
exports.setPrint = function(value) { return exports.setDefault({print: value}).print; }; function setOption(optionName, args) {
exports.setPrompt = function(value) { return exports.setDefault({prompt: value}).prompt; }; var options;
exports.setEncoding = function(value) { return exports.setDefault({encoding: value}).encoding; }; if (args.length) { options = {}; options[optionName] = args[0]; }
exports.setMask = function(value) { return exports.setDefault({mask: value}).mask; }; return exports.setDefault(options)[optionName];
exports.setBufferSize = function(value) { return exports.setDefault({bufSize: value}).bufSize; }; }
exports.setPrint = function() { return setOption('print', arguments); };
exports.setPrompt = function() { return setOption('prompt', arguments); };
exports.setEncoding = function() { return setOption('encoding', arguments); };
exports.setMask = function() { return setOption('mask', arguments); };
exports.setBufferSize = function() { return setOption('bufferSize', arguments); };