GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: deprecate fs.read's string interface · MylesBorins/node@1124de2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • fs.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const isWindows = process.platform === 'win32';
3535

3636
const DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
3737
const errnoException = util._errnoException;
38+
const printDeprecation = require('internal/util').printDeprecationMessage;
3839

3940
function throwOptionsError(options) {
4041
throw new TypeError('Expected options to be either an object or a string, ' +
@@ -584,9 +585,14 @@ fs.openSync = function(path, flags, mode) {
584585
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
585586
};
586587

588+
var readWarned = false;
587589
fs.read = function(fd, buffer, offset, length, position, callback) {
588590
if (!(buffer instanceof Buffer)) {
589591
// legacy string interface (fd, length, position, encoding, callback)
592+
readWarned = printDeprecation('fs.read\'s legacy String interface ' +
593+
'is deprecated. Use the Buffer API as ' +
594+
'mentioned in the documentation instead.',
595+
readWarned);
590596
const cb = arguments[4];
591597
const encoding = arguments[3];
592598

@@ -636,12 +642,17 @@ function tryToStringWithEnd(buf, encoding, end, callback) {
636642
callback(e, buf, end);
637643
}
638644

645+
var readSyncWarned = false;
639646
fs.readSync = function(fd, buffer, offset, length, position) {
640647
var legacy = false;
641648
var encoding;
642649

643650
if (!(buffer instanceof Buffer)) {
644651
// legacy string interface (fd, length, position, encoding, callback)
652+
readSyncWarned = printDeprecation('fs.readSync\'s legacy String interface' +
653+
'is deprecated. Use the Buffer API as ' +
654+
'mentioned in the documentation instead.',
655+
readSyncWarned);
645656
legacy = true;
646657
encoding = arguments[3];
647658

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.