Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Replaced deprecated 'new Buffer(...)' with 'Buffer.from(...)' #539

Merged
merged 1 commit into from
Jul 10, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/__tests__/http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
const req = request(app)
.post(urlString())
.set('Content-Type', 'application/graphql; charset=utf-16');
req.write(new Buffer('{ test(who: "World") }', 'utf16le'));
req.write(Buffer.from('{ test(who: "World") }', 'utf16le'));
const response = await req;

expect(JSON.parse(response.text)).to.deep.equal({
Expand Down Expand Up @@ -940,7 +940,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
const req = request(app)
.post(urlString())
.set('Content-Type', 'application/graphql');
req.write(new Buffer('{ test(who: "World") }'));
req.write(Buffer.from('{ test(who: "World") }'));
const response = await req;

expect(JSON.parse(response.text)).to.deep.equal({
Expand All @@ -957,7 +957,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
post(app, urlString(), graphqlHTTP({ schema: TestSchema }));

const req = request(app).post(urlString());
req.write(new Buffer('{ test(who: "World") }'));
req.write(Buffer.from('{ test(who: "World") }'));
const response = await req;

expect(response.status).to.equal(400);
Expand All @@ -975,7 +975,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
const req = request(app)
.post(urlString())
.set('Content-Type', 'application/graphql');
req.write(new Buffer('{ test(who: "World") }'));
req.write(Buffer.from('{ test(who: "World") }'));
const response = await req;

expect(response.status).to.equal(400);
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ function canDisplayGraphiQL(request: $Request, params: GraphQLParams): boolean {
* Helper function for sending a response using only the core Node server APIs.
*/
function sendResponse(response: $Response, type: string, data: string): void {
const chunk = new Buffer(data, 'utf8');
const chunk = Buffer.from(data, 'utf8');
response.setHeader('Content-Type', type + '; charset=utf-8');
response.setHeader('Content-Length', String(chunk.length));
response.end(chunk);
Expand Down