Skip to content

Commit 0122595

Browse files
Bharat Mhaskarmonkpow
Bharat Mhaskar
authored andcommitted
Instead of new Buffer using Buffer.from as per https://nodejs.org/api/buffer.html\#buffer_new_buffer_string_encoding
1 parent 257415e commit 0122595

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/as.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ function asBuffer(body, options) {
1010
if (Buffer.isBuffer(body)) {
1111
ret = body;
1212
} else if (typeof body === 'object') {
13-
ret = new Buffer(JSON.stringify(body), options.reqBodyEncoding);
13+
ret = Buffer.from(JSON.stringify(body), options.reqBodyEncoding);
1414
} else if (typeof body === 'string') {
15-
ret = new Buffer(body, options.reqBodyEncoding);
15+
ret = Buffer.from(body, options.reqBodyEncoding);
1616
}
1717
return ret;
1818
}

0 commit comments

Comments
 (0)