Skip to main content
BufferConstructor.isEncoding - node__buffer.d.ts - Node documentation
method BufferConstructor.isEncoding

Usage in Deno

```typescript import { type BufferConstructor } from "node:node__buffer.d.ts"; ```
BufferConstructor.isEncoding(encoding: string): encoding is BufferEncoding
Returns `true` if `encoding` is the name of a supported character encoding, or `false` otherwise. ```js import { Buffer } from 'node:buffer'; console.log(Buffer.isEncoding('utf8')); // Prints: true console.log(Buffer.isEncoding('hex')); // Prints: true console.log(Buffer.isEncoding('utf/8')); // Prints: false console.log(Buffer.isEncoding('')); // Prints: false ```

Parameters

encoding: string
A character encoding name to check.

Return Type

encoding is BufferEncoding