Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecate legacy fs.read and fs.readSync arguments #4530

Copy link
Copy link
@feross

Description

@feross
Issue body actions

fs.read and fs.readSync support a little-known alternative usage that lets you get back a String instead of Buffer.

// `fd` is a descriptor to a file that contains 'xyz'
fs.read(fd, 3, 0, 'utf-8',function(err, str, bytesRead) {
  // str is 'xyz'
});
var r = fs.readSync(fd, 3, 0, 'utf-8'); // returns ['xyz', 3] wut?

This doesn't match what node does elsewhere. While preparing this PR, I experienced the very real cost that supporting this old usage causes. It increases the surface area for bugs in node core, as well as user code.

Can we get stats on how much this is used?

Can we, at least as a start, start printing a deprecation warning for this usage?

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.