Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010862
question.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
541 B
Referenced Files
None
Subscribers
None
question.ts
View Options
import
{
createInterface
}
from
"readline"
;
export
async
function
question
(
text
:
string
,
validator
:
(
answer
:
string
)
=>
boolean
)
{
const
rl
=
createInterface
({
input
:
process
.
stdin
,
output
:
process
.
stdout
,
});
let
answer
=
""
;
while
(
answer
==
""
||
!
validator
(
answer
))
{
// eslint-disable-next-line no-await-in-loop
answer
=
await
new
Promise
((
resolve
)
=>
rl
.
question
(
text
,
resolve
));
if
(
!
validator
(
answer
))
{
// eslint-disable-next-line no-console
console
.
log
(
"Try again"
);
}
}
rl
.
close
();
return
answer
;
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:48 (20 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625125
Default Alt Text
question.ts (541 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment