From 4762399aca10d299d1e55537e3a3ceba3dee539b Mon Sep 17 00:00:00 2001 From: "Angie M. Delgado" Date: Fri, 21 Jun 2019 17:06:48 -0500 Subject: [PATCH] doc: add example for Buffer.isEncoding() PR-URL: https://github.com/nodejs/node/pull/28360 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- doc/api/buffer.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 9c7c7e58b81882..d009b1cae8a2b8 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -951,6 +951,20 @@ added: v0.9.1 Returns `true` if `encoding` contains a supported character encoding, or `false` otherwise. +```js +console.log(Buffer.isEncoding('utf-8')); +// Prints: true + +console.log(Buffer.isEncoding('hex')); +// Prints: true + +console.log(Buffer.isEncoding('utf/8')); +// Prints: false + +console.log(Buffer.isEncoding('')); +// Prints: false +``` + ### Class Property: Buffer.poolSize