Skip to content
Myr

perf(compose): optimize `await` (#466)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Do not `await` if the handler is not promise.

authored by Yusuke Wada · committed by GitHub · parent 9edf43c · Browse files · 3 files+70 added−40 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+70 added−40 removed

  • tests:+2 added−2 removed
  • other:+68 added−38 removed

3 files+70 added−40 removed

modified:deno_dist/compose.ts+34 added-19 removed
modified:src/compose.ts+34 added-19 removed
modified:src/hono.test.ts+2 added-2 removed
1031 unmodified lines
1032 })1033 const res = await app.request('http://localhost/')1034 expect(res).not.toBeNull()1035 expect(res.status).toBe(200)1036 expect(await res.text()).toBe('Foo')1037 expect(res.headers.get('content-type')).toBe('text/html; charset=UTF-8')1036 expect(await res.text()).toBe('Bar')1037 expect(res.headers.get('content-type')).toBe('text/plain; charset=UTF-8')1038 })1039})