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

Commit

Permalink
Replaced deprecated 'new Buffer(...)' with 'Buffer.from(...)' (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jul 10, 2019
1 parent 6091cc3 commit e840626
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit e840626

Please sign in to comment.