Git Product home page Git Product logo

Comments (2)

GLanguage avatar GLanguage commented on June 19, 2024 1

簡單來講,問題的核心是process.stdin.end()不再能關閉stdin(可能是node.js版本問題),改為process.stdin.pause()就能暫時解決問題。
然而這不是長久之計。這個庫的設計邏輯似乎有些問題。process.stdin.on()是異步的,這意味著程序會在回調函數處理輸入之前就先運行到下一行,這很符合node.js的異步風格,但並不是交互的主要使用場景。大多時候我們從命令行請求輸入是為了對輸入數據加以操作,如果輸入是異步的,那就無法同步地操作輸入數據。
由於長時間以來,文言的使用者對交互的需求不高,所以這一問題一直沒能被發現。您的issue讓我認識到了這點。我現在在考慮用readline包重寫這個庫,抑或是手動地添加更合理的同步邏輯。屆時我將同時更新範例,加入一個類似猜數遊戲的交互實例。
如果能得到您的幫助,我將不勝感激。

from jiaohu-wy.

GLanguage avatar GLanguage commented on June 19, 2024

抱歉,本庫年代較為久遠,許多邏輯和原理我已不甚清晰,我需要一點時間才能定位問題之源頭。您也可以嘗試閱讀一下源代碼。

from jiaohu-wy.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.