From 7c36ec38f16add6ecfc1a3514514b55c5b610434 Mon Sep 17 00:00:00 2001 From: Kevin Locke <kevin@kevinlocke.name> Date: Mon, 27 Apr 2020 07:09:03 -0600 Subject: [PATCH] doc: add util.types.isArrayBufferView() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function was added by nodejs/node#15663, but was never documented. This commit documents it. PR-URL: https://github.com/nodejs/node/pull/33092 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> --- doc/api/util.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/api/util.md b/doc/api/util.md index 6badb5464e42d0..95e031dc1f0a59 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1259,6 +1259,25 @@ util.types.isAnyArrayBuffer(new ArrayBuffer()); // Returns true util.types.isAnyArrayBuffer(new SharedArrayBuffer()); // Returns true ``` +### `util.types.isArrayBufferView(value)` +<!-- YAML +added: v10.0.0 +--> + +* `value` {any} +* Returns: {boolean} + +Returns `true` if the value is an instance of one of the [`ArrayBuffer`][] +views, such as typed array objects or [`DataView`][]. Equivalent to +[`ArrayBuffer.isView()`][]. + +```js +util.types.isArrayBufferView(new Int8Array()); // true +util.types.isArrayBufferView(Buffer.from('hello world')); // true +util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true +util.types.isArrayBufferView(new ArrayBuffer()); // false +``` + ### `util.types.isArgumentsObject(value)` <!-- YAML added: v10.0.0