You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

koa

Package Overview
Dependencies
Maintainers
11
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa - npm Package Compare versions

Comparing version
3.0.3
to
3.1.0
+12
-4
lib/application.js

@@ -307,7 +307,15 @@ 'use strict'

if (typeof body === 'string') return res.end(body)
if (body instanceof Blob) { return Stream.Readable.from(body.stream()).pipe(res) }
if (body instanceof ReadableStream) { return Stream.Readable.from(body).pipe(res) }
if (body instanceof Response) { return Stream.Readable.from(body?.body || '').pipe(res) }
if (isStream(body)) return body.pipe(res)
let stream = null
if (body instanceof Blob) stream = Stream.Readable.from(body.stream())
else if (body instanceof ReadableStream) stream = Stream.Readable.from(body)
else if (body instanceof Response) stream = Stream.Readable.from(body?.body || '')
else if (isStream(body)) stream = body
if (stream) {
return Stream.pipeline(stream, res, err => {
if (err && ctx.app.listenerCount('error')) ctx.onerror(err)
})
}
// body: json

@@ -314,0 +322,0 @@ body = JSON.stringify(body)

@@ -138,2 +138,10 @@ 'use strict'

this._body = val
const cleanupPreviousStream = () => {
if (original && isStream(original)) {
original.once('error', () => {})
destroy(original)
}
}
// no content

@@ -153,2 +161,3 @@

this.remove('Transfer-Encoding')
cleanupPreviousStream()
return

@@ -167,2 +176,3 @@ }

this.length = Buffer.byteLength(val)
cleanupPreviousStream()
return

@@ -175,2 +185,3 @@ }

this.length = val.length
cleanupPreviousStream()
return

@@ -183,5 +194,4 @@ }

if (original !== val) {
val.once('error', err => this.ctx.onerror(err))
// overwriting
if (original != null) this.remove('Content-Length')
cleanupPreviousStream()
}

@@ -196,2 +206,3 @@

if (setType) this.type = 'bin'
cleanupPreviousStream()
return

@@ -204,2 +215,3 @@ }

this.length = val.size
cleanupPreviousStream()
return

@@ -216,3 +228,3 @@ }

}
cleanupPreviousStream()
return

@@ -224,2 +236,3 @@ }

if (!this.type || !/\bjson\b/i.test(this.type)) this.type = 'json'
cleanupPreviousStream()
},

@@ -226,0 +239,0 @@

{
"name": "koa",
"version": "3.0.3",
"version": "3.1.0",
"description": "Koa web app framework",

@@ -5,0 +5,0 @@ "main": "lib/application.js",