mafintosh / mafintosh/duplexify

`Buffer()` without a `new` keyword is going to be hard-deprecated soon

Open
#10 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
191
Forks
35
PR merge metrics
No merged PRs in 30d

Description

Refs: https://github.com/nodejs/node/pull/8169, https://github.com/nodejs/node/pull/7152.

Two options here:
- Use the new Buffer API — `Buffer.alloc()`/`Buffer.from()`/`Buffer.allocUnsafe()` (requires [a shim](https://github.com/feross/safe-buffer) for v0.10/v0.12 and older v4.x versions prior to v4.5.0).
- Use `new Buffer()` for the time being — just add the `new` keyword everywhere. You should manually check that everything is safe in this case, see the links below for more explanation. That _might_ be hard-deprecated at some later point.

More background:
- https://github.com/ChALkeR/notes/blob/master/Lets-fix-Buffer-API.md
- https://github.com/ChALkeR/notes/blob/master/Buffer-knows-everything.md
- https://github.com/nodejs/node/pull/7152#issuecomment-240880317

Quick grep (you should better re-check):

```
duplexify-3.4.5.tgz/test.js:279: t.same(chunk, Buffer('hello world'))
duplexify-3.4.5.tgz/test.js:290: dup.write(Buffer('hello world'))
```

The grep above only includes the lines that call `Buffer()` without the `new` keyword, if you choose to move to the new API — you should probably also replace `new Buffer(…)` calls.

Contributor guide

No contributing guide indexed for this repository

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

Re-check the repository for Buffer() and new Buffer(...) calls, starting with the occurrences noted in test.js around lines 279 and 290. Read the linked Node.js Buffer guidance and choose the compatible API approach, including the stated older-version constraints. Done means the deprecated calls are addressed and the existing tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.