npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pearwb/readline-prompt

v0.1.1

Published

A readline prompt that survives background console/logger output without losing what you're typing.

Readme

安裝

npm install @pearwb/readline-prompt

基本用法

import ReadlinePrompt from "@pearwb/readline-prompt";

const rl = new ReadlinePrompt();

rl.on("line", (line: string) => {
  console.log(`你輸入了:${line}`);
  // 不用自己呼叫 prompt(),送出一行後會自動顯示下一個提示字元
});

rl.start();

即使有背景輸出同時發生,正在輸入的內容也不會被打亂:

setInterval(() => {
  console.log(`現在時間:${new Date().toISOString()}`);
}, 5000);

API

new ReadlinePrompt(options?)

| 選項 | 型別 | 預設 | 說明 | | -------- | ----------------------- | ---------------- | -------- | | input | NodeJS.ReadableStream | process.stdin | 輸入來源 | | output | NodeJS.WritableStream | process.stdout | 輸出目標 |

rl.start()

建立 readline 介面、套用輸出保護,並顯示第一個提示字元。已經啟動過的話,重複呼叫會被忽略。跟 rl.close() 是一組,標記整個 session 的開始與結束。

rl.close()

清除目前畫面上顯示的那一行(通常是提示字元),還原被修改過的 output.write 與 readline 內部方法,並關閉 readline 介面。即使是在 "line" 事件的非同步處理裡才呼叫(這時 onLine 可能已經自動重新顯示過提示字元),也不會留下殘留的畫面。

事件:"line"

每次使用者按下 Enter 送出一行時觸發,參數是送出的字串(已經是去除換行符號、readline 處理過的結果)。這個套件不解析、不執行指令,line 的內容原封不動交給你自己處理。每次這個事件觸發完,會自動顯示下一個提示字元。

公開 API 就只有 start() 跟 close() 這組生命週期方法,加上 "line" 事件,沒有其他要手動呼叫的東西。

注意事項

這個套件會包一層 readline 內部、未公開的方法(_writeToOutput),藉此分辨「這次輸出是 readline 自己畫的」還是「外部背景輸出」。這個方法在 Node 各版本間一直存在且行為穩定,但它不是 Node 官方保證不變的公開 API。如果你在某個 Node 版本上遇到行為異常,歡迎回報 issue。

授權

BSD-3-Clause