Skip to content

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

Closed
@feross

Description

@feross

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions