Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const { NumberPrompt } = require('enquirer');
const placeholder = require('../../lib/placeholder');
const prompt = new NumberPrompt({
name: 'amount',
message: 'How much do you want to donate?',
float: true,
cursor: 1,
format(input = this.input) {
const str = Intl.NumberFormat(void 0, { style: 'currency', currency: 'USD' }).format(input);
let pos = this.cursor + 1;
// Total number of commas (,) in the formatted string
const totalcommas = str.split(',').length - 1;
// Number of commas (,) to the right of the current cursor position
const extracommas =
Intl.NumberFormat(void 0, { style: 'currency', currency: 'USD' })
.format(
'use strict';
const { NumberPrompt } = require('enquirer');
const placeholder = require('../../lib/placeholder');
const prompt = new NumberPrompt({
name: 'amount',
message: 'How much do you want to donate?',
float: true,
format(input = this.input) {
const str = Intl.NumberFormat(void 0, { style: 'currency', currency: 'USD' }).format(input);
let pos = this.cursor + 1;
// Total number of commas (,) in the formatted string
const totalcommas = str.split(',').length - 1;
// Number of commas (,) to the right of the current cursor position
const extracommas =
Intl.NumberFormat(void 0, { style: 'currency', currency: 'USD' })
.format(
input
'use strict';
const { NumberPrompt } = require('enquirer');
const prompt = new NumberPrompt({
name: 'number',
message: 'Please enter a number'
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
'use strict';
const { NumberPrompt } = require('enquirer');
const prompt = new NumberPrompt({
name: 'number',
message: 'Please enter a number',
initial: 2
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
'use strict';
const { NumberPrompt } = require('enquirer');
const prompt = new NumberPrompt({
name: 'number',
message: 'Please enter a number'
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
export default async customIdText => {
const prompt = new NumberPrompt({
message: `Please enter the ${customIdText}`
});
return prompt.run();
};
'use strict';
const { NumberPrompt } = require('enquirer');
const prompt = new NumberPrompt({
name: 'value',
price: 7.75,
message: 'How many tickets do you need?',
float: false,
validate(state) {
return +state.value < 2 ? 'You must purchase 2 or more tickets' : true;
},
hint() {
if (!this.state.submitted) {
return this.styles.muted(`(${dollars(this.input, this.options.price)})`);
}
},
format() {
return this.state.submitted ? dollars(this.value, this.options.price) : this.value;
}
});