Cloudflare 中文文档
Workers
Workers
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

util

​​ promisify/callbackify

The promisify and callbackify APIs in Node.js provide a means of bridging between a Promise-based programming model and a callback-based model.

The promisify method allows taking a Node.js-style callback function and converting it into a Promise-returning async function:

Similarly to promisify, callbackify converts a Promise-returning async function into a Node.js-style callback function:

callbackify and promisify make it easy to handle all of the challenges that come with bridging between callbacks and promises.

Refer to the Node.js documentation for callbackify and Node.js documentation for promisify for more information.

​​ util.types

The util.types API provides a reliable and efficient way of checking that values are instances of various built-in types.

For more about util.types, refer to the Node.js documentation for util.types.

​​ util.MIMEType

util.MIMEType provides convenience methods that allow you to more easily work with and manipulate MIME types. For example:

For more about util.MIMEType, refer to the Node.js documentation for util.MIMEType.