1 | # Installation
|
2 | > `npm install --save @types/on-headers`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for on-headers (https://github.com/jshttp/on-headers).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/on-headers.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/on-headers/index.d.ts)
|
10 | ````ts
|
11 | /// <reference types="node" />
|
12 |
|
13 | import { ServerResponse } from "http";
|
14 |
|
15 | /**
|
16 | * This will add the listener to fire when headers are emitted for res.
|
17 | * The listener is passed the response object as its context (this).
|
18 | * Headers are considered emitted only once, right before they
|
19 | * are sent to the client.
|
20 | *
|
21 | * When this is called multiple times on the same res, the listeners
|
22 | * are fired in the reverse order they were added.
|
23 | *
|
24 | * @param res HTTP server response object
|
25 | * @param listener Function to call prior to headers being emitted,
|
26 | * the response object is passed as this context.
|
27 | */
|
28 | declare function onHeaders(res: ServerResponse, listener: (this: ServerResponse) => void): void;
|
29 |
|
30 | export = onHeaders;
|
31 |
|
32 | ````
|
33 |
|
34 | ### Additional Details
|
35 | * Last updated: Tue, 07 Nov 2023 09:09:39 GMT
|
36 | * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
37 |
|
38 | # Credits
|
39 | These definitions were written by [John Jeffery](https://github.com/jjeffery), and [BendingBender](https://github.com/BendingBender).
|
40 |
|
\ | No newline at end of file |