diff --git a/body/index.ts b/body/index.ts index 1eca5b6dc..00e8cbaa2 100644 --- a/body/index.ts +++ b/body/index.ts @@ -23,15 +23,15 @@ export function getBodySync( callback: StreamReadCallback, ) { const decoder = new TextDecoder(opts.encoding); - var buffer = ""; - var complete = false; - var sync = true; + let buffer = ""; + let complete = false; + let sync = true; if (typeof stream.readable !== "undefined" && !stream.readable) { done(new Error("stream is not readable")); } - var received = 0; + let received = 0; const limit = opts.limit || 0; const length = opts.expectedLength || null; diff --git a/body/test/body.test.ts b/body/test/body.test.ts index 1389c086f..1f7ac5d29 100644 --- a/body/test/body.test.ts +++ b/body/test/body.test.ts @@ -8,7 +8,7 @@ import { AddressInfo } from "net"; describe("reads the body from the readable stream", () => { test("should read normal body streams", (done) => { - var server = http.createServer((req, res) => { + let server = http.createServer((req, res) => { getBodySync( req, { encoding: "utf-8", limit: 1024 }, @@ -27,8 +27,8 @@ describe("reads the body from the readable stream", () => { }); server.listen(function onListen() { - var addr = server.address() as AddressInfo; - var client = http.request({ method: "POST", port: addr.port }); + let addr = server.address() as AddressInfo; + let client = http.request({ method: "POST", port: addr.port }); client.end("hello, world!"); @@ -48,7 +48,7 @@ describe("reads the body from the readable stream", () => { }); test("should error if the body exceeds the length limit", (done) => { - var server = http.createServer((req, res) => { + let server = http.createServer((req, res) => { getBodySync( req, { encoding: "utf-8", limit: 4 }, @@ -68,8 +68,8 @@ describe("reads the body from the readable stream", () => { }); server.listen(function onListen() { - var addr = server.address() as AddressInfo; - var client = http.request({ method: "POST", port: addr.port }); + let addr = server.address() as AddressInfo; + let client = http.request({ method: "POST", port: addr.port }); client.end("i am a string"); @@ -90,7 +90,7 @@ describe("reads the body from the readable stream", () => { }); test("should error if it isnt the exact length specified", (done) => { - var server = http.createServer((req, res) => { + let server = http.createServer((req, res) => { getBodySync( req, { encoding: "utf-8", limit: 1024, expectedLength: 4 }, @@ -112,8 +112,8 @@ describe("reads the body from the readable stream", () => { }); server.listen(function onListen() { - var addr = server.address() as AddressInfo; - var client = http.request({ method: "POST", port: addr.port }); + let addr = server.address() as AddressInfo; + let client = http.request({ method: "POST", port: addr.port }); client.end("hello, world!");