Types: updated TS definitions.
diff --git a/test/ts/test.ts b/test/ts/test.ts
index ef24d70..4ec9db0 100644
--- a/test/ts/test.ts
+++ b/test/ts/test.ts
@@ -93,6 +93,11 @@
     })
     .then(body => r.return(200, body))
     .catch(e => r.return(501, e.message))
+
+    // js_body_filter
+    r.sendBuffer(Buffer.from("xxx"), {last:true});
+    r.sendBuffer("xxx", {flush: true});
+    r.done();
 }
 
 function fs_module() {
@@ -150,6 +155,7 @@
 function njs_object() {
     njs.dump('asdf');
     njs.version != process.argv[1];
+    njs.on('exit', ()=> {});
 }
 
 function ngx_object() {
diff --git a/ts/ngx_http_js_module.d.ts b/ts/ngx_http_js_module.d.ts
index a7586bf..9ed3b92 100644
--- a/ts/ngx_http_js_module.d.ts
+++ b/ts/ngx_http_js_module.d.ts
@@ -262,12 +262,32 @@
     detached?: boolean
 }
 
+interface NginxHTTPSendBufferOptions {
+    /**
+     * True if data is a last buffer.
+     */
+    last?: boolean
+    /**
+     * True if the buffer should have the flush flag.
+     */
+    flush?: boolean
+}
+
 interface NginxHTTPRequest {
     /**
      * Request arguments object.
      */
     readonly args: NginxHTTPArgs;
     /**
+     * After calling this function, next data chunks will be passed to
+     * the client without calling js_body_filter.
+     *
+     * **Warning:**  May be called only from the js_body_filter function.
+     *
+     * @since 0.5.2
+     */
+    done(): void;
+    /**
      * Writes a string to the error log on the error level of logging.
      * @param message Message to log.
      */
@@ -374,10 +394,23 @@
      */
     return(status: number, body?: NjsStringOrBuffer): void;
     /**
-     * Sends the HTTP headers to the client.
+     * Sends a part of the response body to the client.
      */
     send(part: NjsStringOrBuffer): void;
     /**
+     * Adds data to the chain of data chunks to be forwarded to the next body filter.
+     * The actual forwarding happens later, when the all the data chunks of the current
+     * chain are processed.
+     *
+     * **Warning:**  May be called only from the js_body_filter function.
+     *
+     * @since 0.5.2
+     * @param data Data to send.
+     * @param options Object used to override nginx buffer flags derived from
+     * an incoming data chunk buffer.
+     */
+    sendBuffer(data: NjsStringOrBuffer, options?: NginxHTTPSendBufferOptions): void;
+    /**
      * Sends the HTTP headers to the client.
      */
     sendHeader(): void;
diff --git a/ts/ngx_stream_js_module.d.ts b/ts/ngx_stream_js_module.d.ts
index 6e9d404..849ffce 100644
--- a/ts/ngx_stream_js_module.d.ts
+++ b/ts/ngx_stream_js_module.d.ts
@@ -97,21 +97,44 @@
 
 interface NginxStreamRequest {
     /**
-     * Successfully finalizes the phase handler.
+     * Successfully finalizes the phase handler. An alias to s.done(0).
+     *
+     * @since 0.2.4
+     * @see done()
      */
     allow(): void;
     /**
-     * Finalizes the phase handler and passes control to the next handler.
+     * Passing control to the next handler of the current phase (if any).
+     * An alias to s.done(-5).
+     *
+     * @since 0.2.4
+     * @see done()
      */
     decline(): void;
     /**
      * Finalizes the phase handler with the access error code.
+     * An alias to s.done(403).
+     *
+     * @since 0.2.4
+     * @see done()
      */
     deny(): void;
     /**
-     * Successfully finalizes the current phase handler
-     * or finalizes it with the specified numeric code.
-     * @param code Finalization code.
+     * Sets an exit code for the current phase handler to a code value.
+     * The actual finalization happens when the js handler is completed and
+     * all pending events, for example from ngx.fetch() or setTimeout(),
+     * are processed.
+     *
+     * @param code Finalization code, by default is 0.
+     * Possible code values:
+     *   0 - successful finalization, passing control to the next phase
+     *  -5 - undecided, passing control to the next handler of the current
+     *  phase (if any)
+     * 403 - access is forbidden
+     * @since 0.2.4
+     * @see allow()
+     * @see decline()
+     * @see deny()
      */
     done(code?: number): void;
     /**
@@ -127,6 +150,7 @@
     /**
      * Unregisters the callback set by on() method.
      * @param event Event type to unregister.
+     * @see on()
      */
     off(event: "upload" | "download" | "upstream" | "downstream"): void;
     /**
@@ -138,6 +162,7 @@
      *
      * **Warning:** For string data type bytes invalid in UTF-8 encoding may be
      * converted into the replacement character.
+     * @see off()
      */
     on(event: "upload" | "download",
        callback: (data: NjsByteString, flags: NginxStreamCallbackFlags) => void): void;
@@ -148,13 +173,24 @@
      */
     readonly remoteAddress: NjsByteString;
     /**
-     * Sends the data to the client.
+     * Adds data to the chain of data chunks that will be forwarded in
+     * the forward direction: in download callback to a client; in upload
+     * to an upstream server. The actual forwarding happens later, when the all
+     * the data chunks of the current chain are processed.
+     *
+     * @since 0.2.4
      * @param data Data to send.
      * @param options Object used to override nginx buffer flags derived from
      * an incoming data chunk buffer.
+     * @see on()
      */
     send(data: NjsStringOrBuffer, options?: NginxStreamSendOptions): void;
     /**
+     * The stream session exit status. It is an alias to the $status variable.
+     * @since 0.5.2
+     */
+    readonly status: number;
+    /**
      * nginx variables as Buffers.
      *
      * @since 0.5.0
diff --git a/ts/njs_core.d.ts b/ts/njs_core.d.ts
index 54172d1..808c08f 100644
--- a/ts/njs_core.d.ts
+++ b/ts/njs_core.d.ts
@@ -591,6 +591,11 @@
 interface NjsGlobal {
     readonly version: string;
     dump(value: any, indent?: number): string;
+    /**
+     * Registers a callback for the "exit" event. The callback is called before
+     * the VM is destroyed.
+     */
+    on(event: "exit", callback: () => void): void;
 }
 
 declare const njs: NjsGlobal;