mafintosh / mafintosh/csv-parser

Why's this code so ugly?

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

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.5k
Forks
143
PR merge metrics
No merged PRs in 30d

Description

https://github.com/mafintosh/csv-parser/blob/master/index.js#L3-L4

```js
const [cr] = Buffer.from('\r')
const [nl] = Buffer.from('\n')
```

Apparently it's CR and LF, CR `0x0d` and LF `0x0a`. Why does it need a Buffer to get these values?

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 at index.js lines 3-4 and trace where cr and nl are consumed. Determine whether the Buffer conversion is required for the parser's byte comparisons or can be simplified without changing behavior. Done means documenting the reason or agreeing on a minimal cleanup, then running the repository's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.