azl397985856 / fe-interview

宇宙最强的前端面试指南 (https://lucifer.ren/fe-interview)
Apache License 2.0
2.84k stars 260 forks source link

【每日一题】- 2020-01-20 - node cli如何实现只显示两行信息的功能? #98

Closed azl397985856 closed 4 years ago

azl397985856 commented 4 years ago

如图是显示一行:

image

我们不希望显示超过两行内容,我们超过两行之后需要将之前的内容进行清除

azl397985856 commented 4 years ago

clearLine()和cursorTo(number)配合即可。

如果你不知道这两个API也没有关系,但是如果要实现这样的需求,你的直觉node会提供什么样的api? 这样这道题就从“考察API”转变为“设计API”。 如果你不知道这两个api,但是你能够设想出合理的api,能够完成上述功能,并且api设计足够合理(不能为了实现这个需求而增加一个api),如何和node本身提供的能力结合起来,我觉得肯定会给你加分。

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.