如何检查对象是否属于 IncomingMessage 类型(NodeJS)

How to check if an object is of type IncomingMessage (NodeJS)

我不知道如何导入 NodeJS class,以检查对象。

基本上我想这样做:

if (context.req instanceof IncomingMessage)

https://nodejs.org/api/http.html#http_class_http_incomingmessage

导入/需要 http 模块:

const http = require('http')

//

if (context.req instanceof http.IncomingMessage) {
    //
}