UNPKG

1.03 kBTypeScriptView Raw
1// Type definitions for on-headers 1.0
2// Project: https://github.com/jshttp/on-headers
3// Definitions by: John Jeffery <https://github.com/jjeffery>
4// BendingBender <https://github.com/BendingBender>
5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
7/// <reference types="node" />
8
9import { ServerResponse } from 'http';
10
11/**
12 * This will add the listener to fire when headers are emitted for res.
13 * The listener is passed the response object as its context (this).
14 * Headers are considered emitted only once, right before they
15 * are sent to the client.
16 *
17 * When this is called multiple times on the same res, the listeners
18 * are fired in the reverse order they were added.
19 *
20 * @param res HTTP server response object
21 * @param listener Function to call prior to headers being emitted,
22 * the response object is passed as this context.
23 */
24declare function onHeaders(res: ServerResponse, listener: (this: ServerResponse) => void): void;
25
26export = onHeaders;