trouble-in-terror-town/node_modules/promptly/lib/getOptions.js
Mikolaj 2bbacbea09 did some more work on networking and removed EOS in favor of LRM
did some more work on networking and removed EOS in favor of Light Reflective Mirror
2022-05-31 15:04:31 +02:00

35 lines
825 B
JavaScript

'use strict';
function getOptions(options) {
options = {
// Own options
validator: undefined,
retry: true,
trim: true,
default: undefined,
useDefaultOnTimeout: false,
// `read` package options
silent: false,
replace: '',
input: process.stdin,
output: process.stdout,
timeout: 0,
...options,
};
// Validate that default is a string
if (options.default !== undefined && typeof options.default !== 'string') {
throw new Error('The default option value must be a string');
}
// Normalize validator to an array
if (!Array.isArray(options.validator)) {
options.validator = options.validator ? [options.validator] : [];
}
return options;
}
module.exports = getOptions;