play-dl-fix/gh-pages/interfaces/_internal_.BufferConstructor.html
2021-11-17 12:38:48 +05:30

175 lines
77 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>BufferConstructor | play-dl</title><meta name="description" content="Documentation for play-dl"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">play-dl</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">play-dl</a></li><li><a href="../modules/_internal_.html">&lt;internal&gt;</a></li><li><a href="_internal_.BufferConstructor.html">BufferConstructor</a></li></ul><h1>Interface BufferConstructor</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Raw data is stored in instances of the Buffer class.
A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
Valid string encodings: &#39;ascii&#39;|&#39;utf8&#39;|&#39;utf16le&#39;|&#39;ucs2&#39;(alias of &#39;utf16le&#39;)|&#39;base64&#39;|&#39;base64url&#39;|&#39;binary&#39;(deprecated)|&#39;hex&#39;</p>
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">BufferConstructor</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section tsd-is-external"><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section tsd-is-external"><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#poolSize" class="tsd-kind-icon">pool<wbr/>Size</a></li></ul></section><section class="tsd-index-section tsd-is-external"><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#alloc" class="tsd-kind-icon">alloc</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#allocUnsafe" class="tsd-kind-icon">alloc<wbr/>Unsafe</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#allocUnsafeSlow" class="tsd-kind-icon">alloc<wbr/>Unsafe<wbr/>Slow</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#byteLength" class="tsd-kind-icon">byte<wbr/>Length</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#compare" class="tsd-kind-icon">compare</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#concat" class="tsd-kind-icon">concat</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#from" class="tsd-kind-icon">from</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#isBuffer" class="tsd-kind-icon">is<wbr/>Buffer</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#isEncoding" class="tsd-kind-icon">is<wbr/>Encoding</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#of" class="tsd-kind-icon">of</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group tsd-is-external"><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-interface tsd-is-external"><a id="constructor" class="tsd-anchor"></a><h3>constructor</h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">new <wbr/>Buffer<wbr/>Constructor<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, encoding<span class="tsd-signature-symbol">?: </span><a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">new <wbr/>Buffer<wbr/>Constructor<span class="tsd-signature-symbol">(</span>size<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">new <wbr/>Buffer<wbr/>Constructor<span class="tsd-signature-symbol">(</span>array<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">new <wbr/>Buffer<wbr/>Constructor<span class="tsd-signature-symbol">(</span>arrayBuffer<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">ArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#SharedArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">SharedArrayBuffer</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">new <wbr/>Buffer<wbr/>Constructor<span class="tsd-signature-symbol">(</span>array<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">readonly </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">new <wbr/>Buffer<wbr/>Constructor<span class="tsd-signature-symbol">(</span>buffer<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:189</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new buffer containing the given {str}.</p>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>since v10.0.0 - Use <code>Buffer.from(string[, encoding])</code> instead.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>str: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>String to store in buffer.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> encoding: <a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>encoding to use, optional. Default is &#39;utf8&#39;</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:196</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new buffer of {size} octets.</p>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>since v10.0.0 - Use <code>Buffer.alloc()</code> instead (also see <code>Buffer.allocUnsafe()</code>).</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>size: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>count of octets to allocate.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:203</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new buffer containing the given {array} of octets.</p>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>since v10.0.0 - Use <code>Buffer.from(array)</code> instead.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>array: <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The octets to store.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:212</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Produces a Buffer backed by the same allocated memory as
the given {ArrayBuffer}/{SharedArrayBuffer}.</p>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>since v10.0.0 - Use <code>Buffer.from(arrayBuffer[, byteOffset[, length]])</code> instead.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>arrayBuffer: <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">ArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#SharedArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">SharedArrayBuffer</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The ArrayBuffer with which to share memory.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:219</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new buffer containing the given {array} of octets.</p>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>since v10.0.0 - Use <code>Buffer.from(array)</code> instead.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>array: <span class="tsd-signature-symbol">readonly </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The octets to store.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:226</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Copies the passed {buffer} data onto a new {Buffer} instance.</p>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>since v10.0.0 - Use <code>Buffer.from(buffer)</code> instead.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>buffer: <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The buffer to copy.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group tsd-is-external"><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a id="poolSize" class="tsd-anchor"></a><h3>pool<wbr/>Size</h3><div class="tsd-signature tsd-kind-icon">pool<wbr/>Size<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:529</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>This is the size (in bytes) of pre-allocated internal <code>Buffer</code> instances used
for pooling. This value may be modified.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v0.11.3</p>
</dd></dl></div></section></section><section class="tsd-panel-group tsd-member-group tsd-is-external"><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="alloc" class="tsd-anchor"></a><h3>alloc</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">alloc<span class="tsd-signature-symbol">(</span>size<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, fill<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a>, encoding<span class="tsd-signature-symbol">?: </span><a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:441</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new <code>Buffer</code> of <code>size</code> bytes. If <code>fill</code> is <code>undefined</code>, the<code>Buffer</code> will be zero-filled.</p>
</div><div><pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">5</span><span class="hl-0">);</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">buf</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: &lt;Buffer 00 00 00 00 00&gt;</span>
</code></pre>
<p>If <code>size</code> is larger than {@link constants.MAX_LENGTH} or smaller than 0, <code>ERR_INVALID_ARG_VALUE</code> is thrown.</p>
<p>If <code>fill</code> is specified, the allocated <code>Buffer</code> will be initialized by calling <code>buf.fill(fill)</code>.</p>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">5</span><span class="hl-0">, </span><span class="hl-4">&#39;a&#39;</span><span class="hl-0">);</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">buf</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: &lt;Buffer 61 61 61 61 61&gt;</span>
</code></pre>
<p>If both <code>fill</code> and <code>encoding</code> are specified, the allocated <code>Buffer</code> will be
initialized by calling <code>buf.fill(fill, encoding)</code>.</p>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">11</span><span class="hl-0">, </span><span class="hl-4">&#39;aGVsbG8gd29ybGQ=&#39;</span><span class="hl-0">, </span><span class="hl-4">&#39;base64&#39;</span><span class="hl-0">);</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">buf</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: &lt;Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64&gt;</span>
</code></pre>
<p>Calling <code>Buffer.alloc()</code> can be measurably slower than the alternative <code>Buffer.allocUnsafe()</code> but ensures that the newly created <code>Buffer</code> instance
contents will never contain sensitive data from previous allocations, including
data that might not have been allocated for <code>Buffer</code>s.</p>
<p>A <code>TypeError</code> will be thrown if <code>size</code> is not a number.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v5.10.0</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>size: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The desired length of the new <code>Buffer</code>.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> fill: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> encoding: <a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="allocUnsafe" class="tsd-anchor"></a><h3>alloc<wbr/>Unsafe</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">alloc<wbr/>Unsafe<span class="tsd-signature-symbol">(</span>size<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:478</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new <code>Buffer</code> of <code>size</code> bytes. If <code>size</code> is larger than {@link constants.MAX_LENGTH} or smaller than 0, <code>ERR_INVALID_ARG_VALUE</code> is thrown.</p>
</div><div><p>The underlying memory for <code>Buffer</code> instances created in this way is <em>not</em>
<em>initialized</em>. The contents of the newly created <code>Buffer</code> are unknown and_may contain sensitive data_. Use <code>Buffer.alloc()</code> instead to initialize<code>Buffer</code> instances with zeroes.</p>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">allocUnsafe</span><span class="hl-0">(</span><span class="hl-8">10</span><span class="hl-0">);</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">buf</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints (contents may vary): &lt;Buffer a0 8b 28 3f 01 00 00 00 50 32&gt;</span><br/><br/><span class="hl-3">buf</span><span class="hl-0">.</span><span class="hl-7">fill</span><span class="hl-0">(</span><span class="hl-8">0</span><span class="hl-0">);</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">buf</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: &lt;Buffer 00 00 00 00 00 00 00 00 00 00&gt;</span>
</code></pre>
<p>A <code>TypeError</code> will be thrown if <code>size</code> is not a number.</p>
<p>The <code>Buffer</code> module pre-allocates an internal <code>Buffer</code> instance of
size <code>Buffer.poolSize</code> that is used as a pool for the fast allocation of new<code>Buffer</code> instances created using <code>Buffer.allocUnsafe()</code>,<code>Buffer.from(array)</code>, <code>Buffer.concat()</code>, and the
deprecated<code>new Buffer(size)</code> constructor only when <code>size</code> is less than or equal
to <code>Buffer.poolSize &gt;&gt; 1</code> (floor of <code>Buffer.poolSize</code> divided by two).</p>
<p>Use of this pre-allocated internal memory pool is a key difference between
calling <code>Buffer.alloc(size, fill)</code> vs. <code>Buffer.allocUnsafe(size).fill(fill)</code>.
Specifically, <code>Buffer.alloc(size, fill)</code> will <em>never</em> use the internal <code>Buffer</code>pool, while <code>Buffer.allocUnsafe(size).fill(fill)</code><em>will</em> use the internal<code>Buffer</code> pool if <code>size</code> is less
than or equal to half <code>Buffer.poolSize</code>. The
difference is subtle but can be important when an application requires the
additional performance that <code>Buffer.allocUnsafe()</code> provides.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v5.10.0</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>size: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The desired length of the new <code>Buffer</code>.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="allocUnsafeSlow" class="tsd-anchor"></a><h3>alloc<wbr/>Unsafe<wbr/>Slow</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">alloc<wbr/>Unsafe<wbr/>Slow<span class="tsd-signature-symbol">(</span>size<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:523</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new <code>Buffer</code> of <code>size</code> bytes. If <code>size</code> is larger than {@link constants.MAX_LENGTH} or smaller than 0, <code>ERR_INVALID_ARG_VALUE</code> is thrown. A zero-length <code>Buffer</code> is created
if <code>size</code> is 0.</p>
</div><div><p>The underlying memory for <code>Buffer</code> instances created in this way is <em>not</em>
<em>initialized</em>. The contents of the newly created <code>Buffer</code> are unknown and_may contain sensitive data_. Use <code>buf.fill(0)</code> to initialize
such <code>Buffer</code> instances with zeroes.</p>
<p>When using <code>Buffer.allocUnsafe()</code> to allocate new <code>Buffer</code> instances,
allocations under 4 KB are sliced from a single pre-allocated <code>Buffer</code>. This
allows applications to avoid the garbage collection overhead of creating many
individually allocated <code>Buffer</code> instances. This approach improves both
performance and memory usage by eliminating the need to track and clean up as
many individual <code>ArrayBuffer</code> objects.</p>
<p>However, in the case where a developer may need to retain a small chunk of
memory from a pool for an indeterminate amount of time, it may be appropriate
to create an un-pooled <code>Buffer</code> instance using <code>Buffer.allocUnsafeSlow()</code> and
then copying out the relevant bits.</p>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-5">// Need to keep around a few small chunks of memory.</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">store</span><span class="hl-0"> = [];</span><br/><br/><span class="hl-3">socket</span><span class="hl-0">.</span><span class="hl-7">on</span><span class="hl-0">(</span><span class="hl-4">&#39;readable&#39;</span><span class="hl-0">, () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">let</span><span class="hl-0"> </span><span class="hl-3">data</span><span class="hl-0">;</span><br/><span class="hl-0"> </span><span class="hl-1">while</span><span class="hl-0"> (</span><span class="hl-2">null</span><span class="hl-0"> !== (</span><span class="hl-3">data</span><span class="hl-0"> = </span><span class="hl-3">readable</span><span class="hl-0">.</span><span class="hl-7">read</span><span class="hl-0">())) {</span><br/><span class="hl-0"> </span><span class="hl-5">// Allocate for retained data.</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">sb</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">allocUnsafeSlow</span><span class="hl-0">(</span><span class="hl-8">10</span><span class="hl-0">);</span><br/><br/><span class="hl-0"> </span><span class="hl-5">// Copy the data into the new allocation.</span><br/><span class="hl-0"> </span><span class="hl-3">data</span><span class="hl-0">.</span><span class="hl-7">copy</span><span class="hl-0">(</span><span class="hl-3">sb</span><span class="hl-0">, </span><span class="hl-8">0</span><span class="hl-0">, </span><span class="hl-8">0</span><span class="hl-0">, </span><span class="hl-8">10</span><span class="hl-0">);</span><br/><br/><span class="hl-0"> </span><span class="hl-3">store</span><span class="hl-0">.</span><span class="hl-7">push</span><span class="hl-0">(</span><span class="hl-3">sb</span><span class="hl-0">);</span><br/><span class="hl-0"> }</span><br/><span class="hl-0">});</span>
</code></pre>
<p>A <code>TypeError</code> will be thrown if <code>size</code> is not a number.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v5.12.0</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>size: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The desired length of the new <code>Buffer</code>.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="byteLength" class="tsd-anchor"></a><h3>byte<wbr/>Length</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">byte<wbr/>Length<span class="tsd-signature-symbol">(</span>string<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">ArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#SharedArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">SharedArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBufferView-1" class="tsd-signature-type" data-tsd-kind="Type alias">ArrayBufferView</a>, encoding<span class="tsd-signature-symbol">?: </span><a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:336</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Returns the byte length of a string when encoded using <code>encoding</code>.
This is not the same as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length"><code>String.prototype.length</code></a>, which does not account
for the encoding that is used to convert the string into bytes.</p>
</div><div><p>For <code>&#39;base64&#39;</code>, <code>&#39;base64url&#39;</code>, and <code>&#39;hex&#39;</code>, this function assumes valid input.
For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
return value might be greater than the length of a <code>Buffer</code> created from the
string.</p>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">str</span><span class="hl-0"> = </span><span class="hl-4">&#39;</span><span class="hl-12">\u00bd</span><span class="hl-4"> + </span><span class="hl-12">\u00bc</span><span class="hl-4"> = </span><span class="hl-12">\u00be</span><span class="hl-4">&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-4">`</span><span class="hl-2">${</span><span class="hl-3">str</span><span class="hl-2">}</span><span class="hl-4">: </span><span class="hl-2">${</span><span class="hl-3">str</span><span class="hl-10">.</span><span class="hl-3">length</span><span class="hl-2">}</span><span class="hl-4"> characters, `</span><span class="hl-0"> +</span><br/><span class="hl-0"> </span><span class="hl-4">`</span><span class="hl-2">${</span><span class="hl-3">Buffer</span><span class="hl-10">.</span><span class="hl-7">byteLength</span><span class="hl-10">(</span><span class="hl-3">str</span><span class="hl-10">, </span><span class="hl-4">&#39;utf8&#39;</span><span class="hl-10">)</span><span class="hl-2">}</span><span class="hl-4"> bytes`</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes</span>
</code></pre>
<p>When <code>string</code> is a
<code>Buffer</code>/<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView"><code>DataView</code></a>/[<code>TypedArray</code>](<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/-">https://developer.mozilla.org/en-US/docs/Web/JavaScript/-</a>
Reference/Global_Objects/TypedArray)/<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"><code>ArrayBuffer</code></a>/[<code>SharedArrayBuffer</code>](<a href="https://develop-">https://develop-</a>
er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by <code>.byteLength</code>is returned.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v0.1.90</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>string: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">ArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#SharedArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">SharedArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBufferView-1" class="tsd-signature-type" data-tsd-kind="Type alias">ArrayBufferView</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A value to calculate the length of.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> encoding: <a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><div><p>The number of bytes contained within <code>string</code>.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="compare" class="tsd-anchor"></a><h3>compare</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">compare<span class="tsd-signature-symbol">(</span>buf1<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a>, buf2<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:393</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Compares <code>buf1</code> to <code>buf2</code>, typically for the purpose of sorting arrays of<code>Buffer</code> instances. This is equivalent to calling <code>buf1.compare(buf2)</code>.</p>
</div><div><pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf1</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">from</span><span class="hl-0">(</span><span class="hl-4">&#39;1234&#39;</span><span class="hl-0">);</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf2</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">from</span><span class="hl-0">(</span><span class="hl-4">&#39;0123&#39;</span><span class="hl-0">);</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">arr</span><span class="hl-0"> = [</span><span class="hl-3">buf1</span><span class="hl-0">, </span><span class="hl-3">buf2</span><span class="hl-0">];</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">arr</span><span class="hl-0">.</span><span class="hl-7">sort</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-3">compare</span><span class="hl-0">));</span><br/><span class="hl-5">// Prints: [ &lt;Buffer 30 31 32 33&gt;, &lt;Buffer 31 32 33 34&gt; ]</span><br/><span class="hl-5">// (This result is equal to: [buf2, buf1].)</span>
</code></pre>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v0.11.13</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>buf1: <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a></h5></li><li><h5>buf2: <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><div><p>Either <code>-1</code>, <code>0</code>, or <code>1</code>, depending on the result of the comparison. See <code>compare</code> for details.</p>
</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="concat" class="tsd-anchor"></a><h3>concat</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">concat<span class="tsd-signature-symbol">(</span>list<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">readonly </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol">[]</span>, totalLength<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:375</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Returns a new <code>Buffer</code> which is the result of concatenating all the <code>Buffer</code>instances in the <code>list</code> together.</p>
</div><div><p>If the list has no items, or if the <code>totalLength</code> is 0, then a new zero-length<code>Buffer</code> is returned.</p>
<p>If <code>totalLength</code> is not provided, it is calculated from the <code>Buffer</code> instances
in <code>list</code> by adding their lengths.</p>
<p>If <code>totalLength</code> is provided, it is coerced to an unsigned integer. If the
combined length of the <code>Buffer</code>s in <code>list</code> exceeds <code>totalLength</code>, the result is
truncated to <code>totalLength</code>.</p>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-5">// Create a single `Buffer` from a list of three `Buffer` instances.</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf1</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">10</span><span class="hl-0">);</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf2</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">14</span><span class="hl-0">);</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf3</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">18</span><span class="hl-0">);</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">totalLength</span><span class="hl-0"> = </span><span class="hl-3">buf1</span><span class="hl-0">.</span><span class="hl-3">length</span><span class="hl-0"> + </span><span class="hl-3">buf2</span><span class="hl-0">.</span><span class="hl-3">length</span><span class="hl-0"> + </span><span class="hl-3">buf3</span><span class="hl-0">.</span><span class="hl-3">length</span><span class="hl-0">;</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">totalLength</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: 42</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">bufA</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">concat</span><span class="hl-0">([</span><span class="hl-3">buf1</span><span class="hl-0">, </span><span class="hl-3">buf2</span><span class="hl-0">, </span><span class="hl-3">buf3</span><span class="hl-0">], </span><span class="hl-3">totalLength</span><span class="hl-0">);</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">bufA</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: &lt;Buffer 00 00 00 00 ...&gt;</span><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">bufA</span><span class="hl-0">.</span><span class="hl-3">length</span><span class="hl-0">);</span><br/><span class="hl-5">// Prints: 42</span>
</code></pre>
<p><code>Buffer.concat()</code> may also use the internal <code>Buffer</code> pool like <code>Buffer.allocUnsafe()</code> does.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v0.7.11</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>list: <span class="tsd-signature-symbol">readonly </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>List of <code>Buffer</code> or <a href="_internal_.Uint8Array.html">Uint8Array</a> instances to concatenate.</p>
</div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> totalLength: <span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Total length of the <code>Buffer</code> instances in <code>list</code> when concatenated.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="from" class="tsd-anchor"></a><h3>from</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">from<span class="tsd-signature-symbol">(</span>arrayBuffer<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html#WithImplicitCoercion" class="tsd-signature-type" data-tsd-kind="Type alias">WithImplicitCoercion</a><span class="tsd-signature-symbol">&lt;</span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">ArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#SharedArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">SharedArrayBuffer</a><span class="tsd-signature-symbol">&gt;</span>, byteOffset<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, length<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">from<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">readonly </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">from<span class="tsd-signature-symbol">(</span>data<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html#WithImplicitCoercion" class="tsd-signature-type" data-tsd-kind="Type alias">WithImplicitCoercion</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">readonly </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li><li class="tsd-signature tsd-kind-icon">from<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html#WithImplicitCoercion" class="tsd-signature-type" data-tsd-kind="Type alias">WithImplicitCoercion</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">{ </span>[toPrimitive]<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span>, encoding<span class="tsd-signature-symbol">?: </span><a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:244</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Allocates a new <code>Buffer</code> using an <code>array</code> of bytes in the range <code>0</code> <code>255</code>.
Array entries outside that range will be truncated to fit into it.</p>
</div><div><pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-5">// Creates a new Buffer containing the UTF-8 bytes of the string &#39;buffer&#39;.</span><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-6">buf</span><span class="hl-0"> = </span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">from</span><span class="hl-0">([</span><span class="hl-8">0x62</span><span class="hl-0">, </span><span class="hl-8">0x75</span><span class="hl-0">, </span><span class="hl-8">0x66</span><span class="hl-0">, </span><span class="hl-8">0x66</span><span class="hl-0">, </span><span class="hl-8">0x65</span><span class="hl-0">, </span><span class="hl-8">0x72</span><span class="hl-0">]);</span>
</code></pre>
<p>A <code>TypeError</code> will be thrown if <code>array</code> is not an <code>Array</code> or another type
appropriate for <code>Buffer.from()</code> variants.</p>
<p><code>Buffer.from(array)</code> and <code>Buffer.from(string)</code> may also use the internal<code>Buffer</code> pool like <code>Buffer.allocUnsafe()</code> does.</p>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v5.10.0</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>arrayBuffer: <a href="../modules/_internal_.html#WithImplicitCoercion" class="tsd-signature-type" data-tsd-kind="Type alias">WithImplicitCoercion</a><span class="tsd-signature-symbol">&lt;</span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#ArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">ArrayBuffer</a><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#SharedArrayBuffer-1" class="tsd-signature-type" data-tsd-kind="Variable">SharedArrayBuffer</a><span class="tsd-signature-symbol">&gt;</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> byteOffset: <span class="tsd-signature-type">number</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> length: <span class="tsd-signature-type">number</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:249</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Creates a new Buffer using the passed {data}</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>data: <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">readonly </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>data to create a new Buffer</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:250</li></ul></aside><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>data: <a href="../modules/_internal_.html#WithImplicitCoercion" class="tsd-signature-type" data-tsd-kind="Type alias">WithImplicitCoercion</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Uint8Array-1" class="tsd-signature-type" data-tsd-kind="Variable">Uint8Array</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">readonly </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">&gt;</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:256</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Creates a new Buffer containing the given JavaScript string {str}.
If provided, the {encoding} parameter identifies the character encoding.
If not provided, {encoding} defaults to &#39;utf8&#39;.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>str: <a href="../modules/_internal_.html#WithImplicitCoercion" class="tsd-signature-type" data-tsd-kind="Type alias">WithImplicitCoercion</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">{ </span>[toPrimitive]<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> encoding: <a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="isBuffer" class="tsd-anchor"></a><h3>is<wbr/>Buffer</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">is<wbr/>Buffer<span class="tsd-signature-symbol">(</span>obj<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">obj</span><span class="tsd-signature-symbol"> is </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:283</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Returns <code>true</code> if <code>obj</code> is a <code>Buffer</code>, <code>false</code> otherwise.</p>
</div><div><pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isBuffer</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">alloc</span><span class="hl-0">(</span><span class="hl-8">10</span><span class="hl-0">)); </span><span class="hl-5">// true</span><br/><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isBuffer</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">from</span><span class="hl-0">(</span><span class="hl-4">&#39;foo&#39;</span><span class="hl-0">)); </span><span class="hl-5">// true</span><br/><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isBuffer</span><span class="hl-0">(</span><span class="hl-4">&#39;a string&#39;</span><span class="hl-0">); </span><span class="hl-5">// false</span><br/><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isBuffer</span><span class="hl-0">([]); </span><span class="hl-5">// false</span><br/><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isBuffer</span><span class="hl-0">(</span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-9">Uint8Array</span><span class="hl-0">(</span><span class="hl-8">1024</span><span class="hl-0">)); </span><span class="hl-5">// false</span>
</code></pre>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v0.1.101</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>obj: <span class="tsd-signature-type">any</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">obj</span><span class="tsd-signature-symbol"> is </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="isEncoding" class="tsd-anchor"></a><h3>is<wbr/>Encoding</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">is<wbr/>Encoding<span class="tsd-signature-symbol">(</span>encoding<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">encoding</span><span class="tsd-signature-symbol"> is </span><a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:306</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Returns <code>true</code> if <code>encoding</code> is the name of a supported character encoding,
or <code>false</code> otherwise.</p>
</div><div><pre><code class="language-js"><span class="hl-1">import</span><span class="hl-0"> { </span><span class="hl-3">Buffer</span><span class="hl-0"> } </span><span class="hl-1">from</span><span class="hl-0"> </span><span class="hl-4">&#39;buffer&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isEncoding</span><span class="hl-0">(</span><span class="hl-4">&#39;utf8&#39;</span><span class="hl-0">));</span><br/><span class="hl-5">// Prints: true</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isEncoding</span><span class="hl-0">(</span><span class="hl-4">&#39;hex&#39;</span><span class="hl-0">));</span><br/><span class="hl-5">// Prints: true</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isEncoding</span><span class="hl-0">(</span><span class="hl-4">&#39;utf/8&#39;</span><span class="hl-0">));</span><br/><span class="hl-5">// Prints: false</span><br/><br/><span class="hl-3">console</span><span class="hl-0">.</span><span class="hl-7">log</span><span class="hl-0">(</span><span class="hl-3">Buffer</span><span class="hl-0">.</span><span class="hl-7">isEncoding</span><span class="hl-0">(</span><span class="hl-4">&#39;&#39;</span><span class="hl-0">));</span><br/><span class="hl-5">// Prints: false</span>
</code></pre>
</div><dl class="tsd-comment-tags"><dt>since</dt><dd><p>v0.9.1</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>encoding: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>A character encoding name to check.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">encoding</span><span class="tsd-signature-symbol"> is </span><a href="../modules/_internal_.html#BufferEncoding" class="tsd-signature-type" data-tsd-kind="Type alias">BufferEncoding</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a id="of" class="tsd-anchor"></a><h3>of</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external"><li class="tsd-signature tsd-kind-icon">of<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>items<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:268</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Creates a new Buffer using the passed {data}</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagRest">Rest</span> <span class="tsd-signature-symbol">...</span>items: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="../modules/_internal_.html" class="tsd-signature-type" data-tsd-kind="Namespace">&lt;internal&gt;</a><span class="tsd-signature-symbol">.</span><a href="../modules/_internal_.html#Buffer-1" class="tsd-signature-type" data-tsd-kind="Variable">Buffer</a></h4></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li><li class="current tsd-kind-namespace"><a href="../modules/_internal_.html">&lt;internal&gt;</a><ul><li class=" tsd-kind-namespace tsd-parent-kind-namespace tsd-is-external"><a href="../modules/_internal_._node_stream_consumers_.html">&quot;node:stream/consumers&quot;</a></li><li class=" tsd-kind-namespace tsd-parent-kind-namespace tsd-is-external"><a href="../modules/_internal_._node_stream_promises_.html">&quot;node:stream/promises&quot;</a></li><li class=" tsd-kind-namespace tsd-parent-kind-namespace tsd-is-external"><a href="../modules/_internal_.EventEmitter.html">Event<wbr/>Emitter</a></li><li class=" tsd-kind-namespace tsd-parent-kind-namespace tsd-is-external"><a href="../modules/_internal_.internal.html">internal</a></li></ul></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface tsd-parent-kind-namespace tsd-is-external"><a href="_internal_.BufferConstructor.html" class="tsd-kind-icon">Buffer<wbr/>Constructor</a><ul><li class="tsd-kind-constructor tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#poolSize" class="tsd-kind-icon">pool<wbr/>Size</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#alloc" class="tsd-kind-icon">alloc</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#allocUnsafe" class="tsd-kind-icon">alloc<wbr/>Unsafe</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#allocUnsafeSlow" class="tsd-kind-icon">alloc<wbr/>Unsafe<wbr/>Slow</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#byteLength" class="tsd-kind-icon">byte<wbr/>Length</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#compare" class="tsd-kind-icon">compare</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#concat" class="tsd-kind-icon">concat</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#from" class="tsd-kind-icon">from</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#isBuffer" class="tsd-kind-icon">is<wbr/>Buffer</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#isEncoding" class="tsd-kind-icon">is<wbr/>Encoding</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_internal_.BufferConstructor.html#of" class="tsd-kind-icon">of</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>