• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kwhitley / itty-router / 7117358734

06 Dec 2023 04:28PM UTC coverage: 98.812% (-1.2%) from 100.0%
7117358734

Pull #195

github

kwhitley
resolved merge conflicts
Pull Request #195: New Feature: "flow" to reduce router initialization boilerplate

90 of 92 branches covered (0.0%)

Branch coverage included in aggregate %.

61 of 65 new or added lines in 3 files covered. (93.85%)

4 existing lines in 1 file now uncovered.

409 of 413 relevant lines covered (99.03%)

18.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.96
/src/createResponse.ts
1
export interface ResponseFormatter {
1✔
2
  (body?: any, options?: ResponseInit): Response
1✔
3
}
1✔
4

1✔
5
export interface BodyTransformer {
1✔
6
  (body: any): string
1✔
7
}
1✔
8

1✔
9
export const createResponse =
1✔
10
  (
1✔
11
    format = 'text/plain; charset=utf-8',
12✔
12
    transform?: BodyTransformer
12✔
13
  ): ResponseFormatter =>
12✔
14
  (body, options?: ResponseInit) => {
12✔
15
    const { headers = {}, ...rest } = options || {}
27✔
16

27✔
17
    if (body === undefined) {
27!
NEW
UNCOV
18
      console.log('attempting to transform undefined body')
×
NEW
UNCOV
19
    }
×
20

27✔
21
    if (body?.constructor.name === 'Response' || body === undefined) return body
27✔
22

25✔
23
    if (body === undefined) {
27!
NEW
UNCOV
24
      console.log('succeeeded in transforming undefined body')
×
NEW
UNCOV
25
    }
✔
26

25✔
27
    return new Response(transform ? transform(body) : body, {
27✔
28
      headers: {
27✔
29
        'content-type': format,
27✔
30
        ...headers,
27✔
31
      },
27✔
32
      ...rest,
27✔
33
    })
27✔
34
  }
27✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc