koa icon indicating copy to clipboard operation
koa copied to clipboard

prefer standard functions over external dependencies

Open tinovyatkin opened this issue 4 years ago • 2 comments

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.

  1. Use util.types.isGeneratorFunction when available (Node >= 10) instead of loading external dependency.

  2. Remove depd dependency and use process.emitWarning. depd is huge for the purpose install size - 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.

  3. Use standard (since Node >= 10), Stream.finished instead of external on-finished module when supported. This required small change in context mocking to actually create stream (I think that was necessary anyway for correctness)

tinovyatkin avatar Oct 15 '19 23:10 tinovyatkin

Codecov Report

Merging #1406 into master will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           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.

codecov[bot] avatar Oct 15 '19 23:10 codecov[bot]

i think it is ok, please merge. when to merge?

anlexN avatar Aug 27 '20 04:08 anlexN

closed by https://github.com/koajs/koa/commit/b747e16d75554203a28e55d87296e81f68b992f5

fengmk2 avatar Dec 06 '22 02:12 fengmk2