
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
reloquent
allows to ask user a question.
reloquent(question:string, timeout?:number) => Interface
The function returns a readline instance, with .promise
property, which will resolve
when the user answers the question. You can also optionally supply a timeout argument after
which you want the promise to be rejected.
const reloquent = require('reloquent')
const rl = reloquent('How are you today? ')
rl.promise.then((answer) => {
console.log(`You've answered: %s`, answer) // no timeout
})
const reloquent = require('reloquent')
const rl = reloquent('How are you today? ', 5000) // 5s timeout
rl.promise.catch((err) => {
console.log(err)
console.log('Nevermind...')
})
reloquent.askQuestions(questions:object[], timeout:number, singleValue:string) => Promise<object>
Ask a series of questions and transform them into answers. questions
must be an object of
the following structure:
const reloquent = require('reloquent')
const questions = {
title: {
text: 'Title: ',
validation: (a) => {
if (!a) {
throw new Error('Please enter a title.')
}
},
},
description: {
text: 'Description: ',
postProcess: s => s.trim(),
defaultValue: '',
},
date: {
text: 'Date: ',
getDefault: () => {
return new Promise((resolve) => {
setTimeout(() => resolve(Date.now()), 200)
})
},
},
}
reloquent.askQuestions(questions)
.then((answers) => {
console.log(answers)
})
If you provide the following answers (leaving Date as it is):
Title: title
Description: desc
Date: : [1496188514306]
You will get the following object as the result:
{ title: 'title', description: 'desc', date: 1496188514306 }
A question object supports the following properties:
What is your OS [win]:
can be achieved with () => Promise.resolve(process.platform)
function.You can supply a single value argument, which will ensure that only an answer to the requested
question is returned in resolved promise. This can be useful when you want to use askQuestions
interface to ask a single question.
const reloquent = require('reloquent')
reloquent.askQuestions({
singleQuestion: {
text: 'This is meant to be a single question. Single just like me.',
validation: () => {
console.log('oh no you don\'t have to say anything, it\'s OK.')
},
defaultValue: true,
postProcess: () => 'programming is an art',
},
}, null, 'singleQuestion')
.then((res) => {
console.log(res) // programming is art
})
(c) Sobesednik-Media 2017
0.2.0
askQuestions
: ask multiple questions.FAQs
Ask user configurable questions via read-line.
The npm package reloquent receives a total of 49 weekly downloads. As such, reloquent popularity was classified as not popular.
We found that reloquent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.