koa
koa copied to clipboard
prefer standard functions over external dependencies
This PR fixes three issues, two happens to be related to generator functions middleware. While this functionality will be removed completely in Koa 3.0, the next major version is not on the radar yet (unfortunately), but these small changes will make Koa a little bit faster and safer today.
-
Use
util.types.isGeneratorFunction
when available (Node >= 10) instead of loading external dependency. -
Remove
depd
dependency and useprocess.emitWarning
.depd
is huge for the purpose - it's 500+ lines of code (twice as big as Koa'application.js
) and used just once - to deprecate generator middleware.process.emitWarning
coupled with--no-deprecation
and--trace-deprecation
command-line flags resulting in the same functionality while having one less external dependency to load. -
Use standard (since Node >= 10),
Stream.finished
instead of externalon-finished
module when supported. This required small change in context mocking to actually create stream (I think that was necessary anyway for correctness)
Codecov Report
Merging #1406 into master will increase coverage by
0.00%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #1406 +/- ##
=======================================
Coverage 99.38% 99.38%
=======================================
Files 4 4
Lines 487 490 +3
Branches 136 141 +5
=======================================
+ Hits 484 487 +3
Partials 3 3
Impacted Files | Coverage Δ | |
---|---|---|
lib/application.js | 98.33% <100.00%> (+0.04%) |
:arrow_up: |
lib/response.js | 99.37% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update b7d8c97...05999f6. Read the comment docs.
i think it is ok, please merge. when to merge?
closed by https://github.com/koajs/koa/commit/b747e16d75554203a28e55d87296e81f68b992f5