6 var Input = require('./input');
9 * Extention of the Input prompt specifically for use with number inputs.
12 class NumberPrompt extends Input {
14 if (input && typeof input === 'string') {
16 // Match a number in the input
17 let numberMatch = input.match(/(^-?\d+|^\d+\.\d*|^\d*\.\d+)(e\d+)?$/);
18 // If a number is found, return that input.
20 return Number(numberMatch[0]);
24 // If the input was invalid return the default value.
25 return this.opt.default == null ? NaN : this.opt.default;
29 module.exports = NumberPrompt;