Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/franciscop/readline-polyfill
Readline polyfill using only `node:events` and `node:tty`
https://github.com/franciscop/readline-polyfill
Last synced: 13 days ago
JSON representation
Readline polyfill using only `node:events` and `node:tty`
- Host: GitHub
- URL: https://github.com/franciscop/readline-polyfill
- Owner: franciscop
- Created: 2022-07-07T23:15:47.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-07-16T11:15:50.000Z (over 2 years ago)
- Last Synced: 2024-04-23T13:43:35.826Z (7 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Readline Polyfill
Polyfill for `readline` in Node.js using only the basics of `stdin`, `stdout`, `tty` and `EventEmitter`. Some of the examples in Node.js website work. To test them, you can run the examples and interact with them:
```bash
// Works, meaning they have been polyfilled without using `readline`:
node example-1.js
node example-2.js
node example-3.js// Does not work, since we also need to properly polyfill stdin and stdout:
bun example-1.bun.js// TODO/future: Promises API for Readline:
node example-promises-1.js
```## Contributing
We need to create `process.stdin` and `process.stdout` that work as the native ones based on `Bun.stdin` and `Bun.stdout`. For this, we are working on `std-polyfill.js`.
So right now if you want to help, we need to get `std-polyfill.js` working. Some tests or automated examples would be nice not to have to run both at the same time, but now with `bun example-1.bun.js` you can see issues in `std-polyfill.js`.
Question: do we make the minimum that works, or do we polyfill the whole `stdin` and `stdout`? (How much work is that??)
For now let's do the basic, we can always extend it later. Let's try to use things as documented on the Official Node.js documentation, e.g. create new class names, extending EventEmitter where appropriate, etc.
## Sources
- Many general snippets: https://www.jasnell.me/posts/webstreams
- NodeStream: https://nodejs.org/api/stream.html
- WebStream: https://nodejs.org/api/webstreams.html