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

kwhitley / itty-router / 5139182859

01 Jun 2023 01:04AM UTC coverage: 100.0%. Remained the same
5139182859

push

github

kwhitley
released v4.0.8 - added prettier

67 of 67 branches covered (100.0%)

Branch coverage included in aggregate %.

378 of 378 relevant lines covered (100.0%)

18.69 hits per line

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

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

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

1✔
9
type ResponseFormatterOptions = {
1✔
10
  headers?: object
1✔
11
} & ResponseInit
1✔
12

1✔
13
export const createResponse =
1✔
14
  (
1✔
15
    format = 'text/plain; charset=utf-8',
1✔
16
    transform?: BodyTransformer
1✔
17
  ): ResponseFormatter =>
1✔
18
  (body, options: ResponseFormatterOptions = {}) => {
1✔
19
    const { headers = {}, ...rest } = options
18✔
20

18✔
21
    if (body?.constructor.name === 'Response') return body
18✔
22

17✔
23
    return new Response(transform ? transform(body) : body, {
18✔
24
      headers: {
18✔
25
        'content-type': format,
18✔
26
        ...headers,
18✔
27
      },
18✔
28
      ...rest,
18✔
29
    })
18✔
30
  }
18✔
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