Skip to content
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

safe-buffer doesn't zero-fill by default, its just a polyfill. #2578

Merged
merged 1 commit into from Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helpers.js
Expand Up @@ -36,7 +36,7 @@ function isReadStream (rs) {
}

function toBase64 (str) {
return (new Buffer(str || '', 'utf8')).toString('base64')
return Buffer.from(str || '', 'utf8').toString('base64')
}

function copy (obj) {
Expand Down
2 changes: 1 addition & 1 deletion lib/multipart.js
Expand Up @@ -72,7 +72,7 @@ Multipart.prototype.build = function (parts, chunked) {
if (typeof part === 'number') {
part = part.toString()
}
return chunked ? body.append(part) : body.push(new Buffer(part))
return chunked ? body.append(part) : body.push(Buffer.from(part))
}

if (self.request.preambleCRLF) {
Expand Down
2 changes: 1 addition & 1 deletion lib/oauth.js
Expand Up @@ -71,7 +71,7 @@ OAuth.prototype.buildBodyHash = function(_oauth, body) {
shasum.update(body || '')
var sha1 = shasum.digest('hex')

return new Buffer(sha1).toString('base64')
return Buffer.from(sha1).toString('base64')
}

OAuth.prototype.concatParams = function (oa, sep, wrap) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -47,7 +47,7 @@
"safe-buffer": "^5.0.1",
"stringstream": "~0.0.4",
"tough-cookie": "~2.3.0",
"tunnel-agent": "^0.5.0",
"tunnel-agent": "^0.6.0",
"uuid": "^3.0.0"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions request.js
Expand Up @@ -418,7 +418,7 @@ Request.prototype.init = function (options) {

function setContentLength () {
if (isTypedArray(self.body)) {
self.body = new Buffer(self.body)
self.body = Buffer.from(self.body)
}

if (!self.hasHeader('content-length')) {
Expand Down Expand Up @@ -1122,7 +1122,7 @@ Request.prototype.readResponseBody = function (response) {
}
debug('emitting complete', self.uri.href)
if (typeof response.body === 'undefined' && !self._json) {
response.body = self.encoding === null ? new Buffer(0) : ''
response.body = self.encoding === null ? Buffer.alloc(0) : ''
}
self.emit('complete', response, response.body)
})
Expand Down