-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove deprecated Buffer.write(...) #5048
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
'use strict'; | ||
|
||
const binding = process.binding('buffer'); | ||
const internalUtil = require('internal/util'); | ||
const bindingObj = {}; | ||
|
||
exports.Buffer = Buffer; | ||
|
@@ -533,10 +532,6 @@ Buffer.prototype.fill = function fill(val, start, end) { | |
}; | ||
|
||
|
||
var writeWarned = false; | ||
const writeMsg = 'Buffer.write(string, encoding, offset, length) is ' + | ||
'deprecated. Use write(string[, offset[, length]]' + | ||
'[, encoding]) instead.'; | ||
Buffer.prototype.write = function(string, offset, length, encoding) { | ||
// Buffer#write(string); | ||
if (offset === undefined) { | ||
|
@@ -561,14 +556,12 @@ Buffer.prototype.write = function(string, offset, length, encoding) { | |
encoding = length; | ||
length = undefined; | ||
} | ||
|
||
// XXX legacy write(string, encoding, offset, length) - remove in v0.13 | ||
} else { | ||
writeWarned = internalUtil.printDeprecationMessage(writeMsg, writeWarned); | ||
var swap = encoding; | ||
encoding = offset; | ||
offset = length >>> 0; | ||
length = swap; | ||
// if someone is still calling the obsolete form of write(), tell them. | ||
// we don't want eg buf.write("foo", "utf8", 10) to silently turn into | ||
// buf.write("foo", "utf8"), so we can't ignore extra args | ||
throw new Error('Buffer.write(string, encoding, offset[, length]) ' + | ||
'is no longer supported'); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps instead of flat out removing this branch, we should keep it and throw instead when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can make it throw There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dcposch Will I'd prefer an explicit throw, at least for now. |
||
var remaining = this.length - offset; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically should be ``Buffer.write(string, encoding[, offset[, length]])'`, but I really don't care whether it's changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string, encoding
fits into the current signature, so it's not deprecated. I made that mistake in the first grep :-).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChALkeR Sorry, not following.