lsongdev / lsongdev/input-event

[Suggestion] Prevent usage of openSync

Open
#22 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
65
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Are the following lines in lib/index.js really necessary?

this.fd = fs.openSync(this.device, this.flags);
this.input = fs.createReadStream(null, this);

At least, you do not check for a valid file descriptor first. So why not forward the device string directly to the createReadStream function instead of null?

this.input = fs.createReadStream(this.device, this);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/index.js by tracing how fs.openSync, this.fd, and fs.createReadStream(null, this) are used. Compare that flow with passing this.device directly to createReadStream, then verify that input events from Linux devices are still read correctly and that no required file-descriptor behavior is lost.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
operating-systems
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.