mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
178 lines
100 KiB
HTML
178 lines
100 KiB
HTML
<!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>BufferConstructor | liquidjs</title><meta name="description" content="Documentation for liquidjs"/><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 defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></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">liquidjs</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">liquidjs</a></li><li><a href="../modules/_internal_.html"><internal></a></li><li><a href="_internal_.BufferConstructor.html">BufferConstructor</a></li></ul><h1>Interface BufferConstructor</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><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: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></section><div class="tsd-signature"><span class="tsd-signature-keyword">interface </span><span class="tsd-kind-interface">BufferConstructor</span> <span class="tsd-signature-symbol">{ </span><br/><span> </span><a class="tsd-kind-constructor-signature" href="_internal_.BufferConstructor.html#constructor.new_BufferConstructor">new BufferConstructor</a><span class="tsd-signature-keyword">new </span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">str</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?: </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-constructor-signature" href="_internal_.BufferConstructor.html#constructor.new_BufferConstructor-1">new BufferConstructor</a><span class="tsd-signature-keyword">new </span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-constructor-signature" href="_internal_.BufferConstructor.html#constructor.new_BufferConstructor-2">new BufferConstructor</a><span class="tsd-signature-keyword">new </span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">array</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-constructor-signature" href="_internal_.BufferConstructor.html#constructor.new_BufferConstructor-3">new BufferConstructor</a><span class="tsd-signature-keyword">new </span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">arrayBuffer</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><a href="_internal_.SharedArrayBuffer.html" class="tsd-signature-type tsd-kind-interface">SharedArrayBuffer</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-constructor-signature" href="_internal_.BufferConstructor.html#constructor.new_BufferConstructor-4">new BufferConstructor</a><span class="tsd-signature-keyword">new </span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">array</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-keyword">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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-constructor-signature" href="_internal_.BufferConstructor.html#constructor.new_BufferConstructor-5">new BufferConstructor</a><span class="tsd-signature-keyword">new </span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">buffer</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-property" href="_internal_.BufferConstructor.html#poolSize">poolSize</a><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#alloc.alloc-1">alloc</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, <span class="tsd-kind-parameter">fill</span><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><span class="tsd-signature-type">Uint8Array</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?: </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#allocUnsafe.allocUnsafe-1">allocUnsafe</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#allocUnsafeSlow.allocUnsafeSlow-1">allocUnsafeSlow</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#byteLength.byteLength-1">byteLength</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">string</span><span class="tsd-signature-symbol">: </span><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">ArrayBuffer</span><br/><span> </span><span class="tsd-signature-symbol">| </span><a href="_internal_.SharedArrayBuffer.html" class="tsd-signature-type tsd-kind-interface">SharedArrayBuffer</a><br/><span> </span><span class="tsd-signature-symbol">| </span><a href="../types/_internal_.ArrayBufferView.html" class="tsd-signature-type tsd-kind-type-alias">ArrayBufferView</a>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?: </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type 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><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#compare.compare-1">compare</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">buf1</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span>, <span class="tsd-kind-parameter">buf2</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">-1</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">0</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">1</span><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#concat.concat-1">concat</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">list</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-keyword">readonly </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">[]</span>, <span class="tsd-kind-parameter">totalLength</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#copyBytesFrom.copyBytesFrom-1">copyBytesFrom</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">view</span><span class="tsd-signature-symbol">: </span><a href="../types/_internal_.TypedArray.html" class="tsd-signature-type tsd-kind-type-alias">TypedArray</a>, <span class="tsd-kind-parameter">offset</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, <span class="tsd-kind-parameter">length</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#from.from-1">from</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">arrayBuffer</span><span class="tsd-signature-symbol">: </span><a href="../types/_internal_.WithImplicitCoercion.html" class="tsd-signature-type tsd-kind-type-alias">WithImplicitCoercion</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><a href="_internal_.SharedArrayBuffer.html" class="tsd-signature-type tsd-kind-interface">SharedArrayBuffer</a><span class="tsd-signature-symbol">></span>, <span class="tsd-kind-parameter">byteOffset</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, <span class="tsd-kind-parameter">length</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#from.from-2">from</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">data</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-keyword">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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#from.from-3">from</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">data</span><span class="tsd-signature-symbol">: </span><a href="../types/_internal_.WithImplicitCoercion.html" class="tsd-signature-type tsd-kind-type-alias">WithImplicitCoercion</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-keyword">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><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#from.from-4">from</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">str</span><span class="tsd-signature-symbol">: </span><a href="../types/_internal_.WithImplicitCoercion.html" class="tsd-signature-type tsd-kind-type-alias">WithImplicitCoercion</a><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-symbol">{ </span><br/><span> </span><span class="tsd-kind-call-signature">[toPrimitive]</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">hint</span><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">string</span><span class="tsd-signature-symbol">; </span><br/><span> </span><span class="tsd-signature-symbol">}</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?: </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#isBuffer.isBuffer-1">isBuffer</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">obj</span><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-kind-parameter">obj</span><span class="tsd-signature-keyword"> is </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#isEncoding.isEncoding-1">isEncoding</a><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">encoding</span><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-kind-parameter">encoding</span><span class="tsd-signature-keyword"> is </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a><span class="tsd-signature-symbol">; </span><br/><span> </span><a class="tsd-kind-call-signature" href="_internal_.BufferConstructor.html#of.of-1">of</a><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">items</span><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="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:267</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="_internal_.BufferConstructor.html#constructor" class="tsd-index-link deprecated tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="_internal_.BufferConstructor.html#poolSize" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>pool<wbr/>Size</span></a>
|
||
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="_internal_.BufferConstructor.html#alloc" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>alloc</span></a>
|
||
<a href="_internal_.BufferConstructor.html#allocUnsafe" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>alloc<wbr/>Unsafe</span></a>
|
||
<a href="_internal_.BufferConstructor.html#allocUnsafeSlow" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>alloc<wbr/>Unsafe<wbr/>Slow</span></a>
|
||
<a href="_internal_.BufferConstructor.html#byteLength" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>byte<wbr/>Length</span></a>
|
||
<a href="_internal_.BufferConstructor.html#compare" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>compare</span></a>
|
||
<a href="_internal_.BufferConstructor.html#concat" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>concat</span></a>
|
||
<a href="_internal_.BufferConstructor.html#copyBytesFrom" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>copy<wbr/>Bytes<wbr/>From</span></a>
|
||
<a href="_internal_.BufferConstructor.html#from" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>from</span></a>
|
||
<a href="_internal_.BufferConstructor.html#isBuffer" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>is<wbr/>Buffer</span></a>
|
||
<a href="_internal_.BufferConstructor.html#isEncoding" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>is<wbr/>Encoding</span></a>
|
||
<a href="_internal_.BufferConstructor.html#of" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>of</span></a>
|
||
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Constructors</h2></summary><section><section class="tsd-panel tsd-member tsd-is-external"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="deprecated">constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_BufferConstructor" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Buffer<wbr/>Constructor</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">str</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#constructor.new_BufferConstructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Allocates a new buffer containing the given {str}.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">str</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>String to store in buffer.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">encoding</span>: <a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a></span><div class="tsd-comment tsd-typography"><p>encoding to use, optional. Default is 'utf8'</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Deprecated" class="tsd-anchor"></a>Deprecated<a href="#Deprecated" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>since v10.0.0 - Use <code>Buffer.from(string[, encoding])</code> instead.</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:275</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_BufferConstructor-1" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Buffer<wbr/>Constructor</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#constructor.new_BufferConstructor-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Allocates a new buffer of {size} octets.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">size</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>count of octets to allocate.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Deprecated-1" class="tsd-anchor"></a>Deprecated<a href="#Deprecated-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>since v10.0.0 - Use <code>Buffer.alloc()</code> instead (also see <code>Buffer.allocUnsafe()</code>).</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:282</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_BufferConstructor-2" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Buffer<wbr/>Constructor</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#constructor.new_BufferConstructor-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Allocates a new buffer containing the given {array} of octets.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">array</span>: <span class="tsd-signature-type">Uint8Array</span></span><div class="tsd-comment tsd-typography"><p>The octets to store.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Deprecated-2" class="tsd-anchor"></a>Deprecated<a href="#Deprecated-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>since v10.0.0 - Use <code>Buffer.from(array)</code> instead.</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:289</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_BufferConstructor-3" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Buffer<wbr/>Constructor</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">arrayBuffer</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#constructor.new_BufferConstructor-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Produces a Buffer backed by the same allocated memory as
|
||
the given {ArrayBuffer}/{SharedArrayBuffer}.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">arrayBuffer</span>: <span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><a href="_internal_.SharedArrayBuffer.html" class="tsd-signature-type tsd-kind-interface">SharedArrayBuffer</a></span><div class="tsd-comment tsd-typography"><p>The ArrayBuffer with which to share memory.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Deprecated-3" class="tsd-anchor"></a>Deprecated<a href="#Deprecated-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>since v10.0.0 - Use <code>Buffer.from(arrayBuffer[, byteOffset[, length]])</code> instead.</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:297</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_BufferConstructor-4" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Buffer<wbr/>Constructor</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">array</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#constructor.new_BufferConstructor-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Allocates a new buffer containing the given {array} of octets.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">array</span>: <span class="tsd-signature-keyword">readonly </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span></span><div class="tsd-comment tsd-typography"><p>The octets to store.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Deprecated-4" class="tsd-anchor"></a>Deprecated<a href="#Deprecated-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>since v10.0.0 - Use <code>Buffer.from(array)</code> instead.</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:304</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_BufferConstructor-5" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Buffer<wbr/>Constructor</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">buffer</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#constructor.new_BufferConstructor-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Copies the passed {buffer} data onto a new {Buffer} instance.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">buffer</span>: <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></span><div class="tsd-comment tsd-typography"><p>The buffer to copy.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Deprecated-5" class="tsd-anchor"></a>Deprecated<a href="#Deprecated-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>since v10.0.0 - Use <code>Buffer.from(buffer)</code> instead.</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:311</li></ul></aside></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Properties</h2></summary><section><section class="tsd-panel tsd-member tsd-is-external"><a id="poolSize" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>pool<wbr/>Size</span><a href="#poolSize" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">pool<wbr/>Size</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><div class="tsd-comment tsd-typography"><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><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since" class="tsd-anchor"></a>Since<a href="#Since" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v0.11.3</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:641</li></ul></aside></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Methods</h2></summary><section><section class="tsd-panel tsd-member tsd-is-external"><a id="alloc" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>alloc</span><a href="#alloc" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="alloc.alloc-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">alloc</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span>, <span class="tsd-kind-parameter">fill</span><span class="tsd-signature-symbol">?</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#alloc.alloc-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><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>
|
||
<pre><code class="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">5</span><span class="hl-1">);</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: <Buffer 00 00 00 00 00></span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
<p>If <code>size</code> is larger than constants.MAX_LENGTH or smaller than 0, <code>ERR_OUT_OF_RANGE</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="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">5</span><span class="hl-1">, </span><span class="hl-2">'a'</span><span class="hl-1">);</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: <Buffer 61 61 61 61 61></span>
|
||
</code><button type="button">Copy</button></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="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">11</span><span class="hl-1">, </span><span class="hl-2">'aGVsbG8gd29ybGQ='</span><span class="hl-1">, </span><span class="hl-2">'base64'</span><span class="hl-1">);</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64></span>
|
||
</code><button type="button">Copy</button></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><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">size</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>The desired length of the new <code>Buffer</code>.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">fill</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><span class="tsd-signature-type">Uint8Array</span></span><div class="tsd-comment tsd-typography"><p>A value to pre-fill the new <code>Buffer</code> with.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">encoding</span>: <a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a></span><div class="tsd-comment tsd-typography"><p>If <code>fill</code> is a string, this is its encoding.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-1" class="tsd-anchor"></a>Since<a href="#Since-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v5.10.0</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:554</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="allocUnsafe" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>alloc<wbr/>Unsafe</span><a href="#allocUnsafe" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="allocUnsafe.allocUnsafe-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">alloc<wbr/>Unsafe</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#allocUnsafe.allocUnsafe-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Allocates a new <code>Buffer</code> of <code>size</code> bytes. If <code>size</code> is larger than constants.MAX_LENGTH or smaller than 0, <code>ERR_OUT_OF_RANGE</code> is thrown.</p>
|
||
<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 <em>may contain sensitive data</em>. Use <code>Buffer.alloc()</code> instead to initialize<code>Buffer</code> instances with zeroes.</p>
|
||
<pre><code class="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">allocUnsafe</span><span class="hl-1">(</span><span class="hl-13">10</span><span class="hl-1">);</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32></span><br/><br/><span class="hl-10">buf</span><span class="hl-1">.</span><span class="hl-0">fill</span><span class="hl-1">(</span><span class="hl-13">0</span><span class="hl-1">);</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00></span>
|
||
</code><button type="button">Copy</button></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>,
|
||
and <code>Buffer.concat()</code> only when <code>size</code> is less than <code>Buffer.poolSize >>> 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><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">size</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>The desired length of the new <code>Buffer</code>.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-2" class="tsd-anchor"></a>Since<a href="#Since-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v5.10.0</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:590</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="allocUnsafeSlow" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>alloc<wbr/>Unsafe<wbr/>Slow</span><a href="#allocUnsafeSlow" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="allocUnsafeSlow.allocUnsafeSlow-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">alloc<wbr/>Unsafe<wbr/>Slow</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">size</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#allocUnsafeSlow.allocUnsafeSlow-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Allocates a new <code>Buffer</code> of <code>size</code> bytes. If <code>size</code> is larger than constants.MAX_LENGTH or smaller than 0, <code>ERR_OUT_OF_RANGE</code> is thrown. A zero-length <code>Buffer</code> is created if
|
||
<code>size</code> is 0.</p>
|
||
<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 <em>may contain sensitive data</em>. 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 KiB 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="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-12">// Need to keep around a few small chunks of memory.</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">store</span><span class="hl-1"> = [];</span><br/><br/><span class="hl-10">socket</span><span class="hl-1">.</span><span class="hl-0">on</span><span class="hl-1">(</span><span class="hl-2">'readable'</span><span class="hl-1">, () </span><span class="hl-8">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-8">let</span><span class="hl-1"> </span><span class="hl-10">data</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-9">while</span><span class="hl-1"> (</span><span class="hl-8">null</span><span class="hl-1"> !== (</span><span class="hl-10">data</span><span class="hl-1"> = </span><span class="hl-10">readable</span><span class="hl-1">.</span><span class="hl-0">read</span><span class="hl-1">())) {</span><br/><span class="hl-1"> </span><span class="hl-12">// Allocate for retained data.</span><br/><span class="hl-1"> </span><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">sb</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">allocUnsafeSlow</span><span class="hl-1">(</span><span class="hl-13">10</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-12">// Copy the data into the new allocation.</span><br/><span class="hl-1"> </span><span class="hl-10">data</span><span class="hl-1">.</span><span class="hl-0">copy</span><span class="hl-1">(</span><span class="hl-10">sb</span><span class="hl-1">, </span><span class="hl-13">0</span><span class="hl-1">, </span><span class="hl-13">0</span><span class="hl-1">, </span><span class="hl-13">10</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-10">store</span><span class="hl-1">.</span><span class="hl-0">push</span><span class="hl-1">(</span><span class="hl-10">sb</span><span class="hl-1">);</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
<p>A <code>TypeError</code> will be thrown if <code>size</code> is not a number.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">size</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>The desired length of the new <code>Buffer</code>.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-3" class="tsd-anchor"></a>Since<a href="#Since-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v5.12.0</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:635</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="byteLength" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>byte<wbr/>Length</span><a href="#byteLength" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="byteLength.byteLength-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">byte<wbr/>Length</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">string</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><a href="#byteLength.byteLength-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><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>
|
||
<p>For <code>'base64'</code>, <code>'base64url'</code>, and <code>'hex'</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="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">str</span><span class="hl-1"> = </span><span class="hl-2">'</span><span class="hl-14">\u00bd</span><span class="hl-2"> + </span><span class="hl-14">\u00bc</span><span class="hl-2"> = </span><span class="hl-14">\u00be</span><span class="hl-2">'</span><span class="hl-1">;</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">`</span><span class="hl-8">${</span><span class="hl-10">str</span><span class="hl-8">}</span><span class="hl-2">: </span><span class="hl-8">${</span><span class="hl-10">str</span><span class="hl-5">.</span><span class="hl-10">length</span><span class="hl-8">}</span><span class="hl-2"> characters, `</span><span class="hl-1"> +</span><br/><span class="hl-1"> </span><span class="hl-2">`</span><span class="hl-8">${</span><span class="hl-10">Buffer</span><span class="hl-5">.</span><span class="hl-0">byteLength</span><span class="hl-5">(</span><span class="hl-10">str</span><span class="hl-5">, </span><span class="hl-2">'utf8'</span><span class="hl-5">)</span><span class="hl-8">}</span><span class="hl-2"> bytes`</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes</span>
|
||
</code><button type="button">Copy</button></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>](https://develop-
|
||
<a href="http://er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer">er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer</a>), the byte length as reported by <code>.byteLength</code>is returned.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">string</span>: <br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">string</span><br/><span> </span><span class="tsd-signature-symbol">| </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><br/><span> </span><span class="tsd-signature-symbol">| </span><span class="tsd-signature-type">ArrayBuffer</span><br/><span> </span><span class="tsd-signature-symbol">| </span><a href="_internal_.SharedArrayBuffer.html" class="tsd-signature-type tsd-kind-interface">SharedArrayBuffer</a><br/><span> </span><span class="tsd-signature-symbol">| </span><a href="../types/_internal_.ArrayBufferView.html" class="tsd-signature-type tsd-kind-type-alias">ArrayBufferView</a></span><div class="tsd-comment tsd-typography"><p>A value to calculate the length of.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">encoding</span>: <a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a></span><div class="tsd-comment tsd-typography"><p>If <code>string</code> is a string, this is its encoding.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><p>The number of bytes contained within <code>string</code>.</p>
|
||
<div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-4" class="tsd-anchor"></a>Since<a href="#Since-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v0.1.90</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:429</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="compare" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>compare</span><a href="#compare" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="compare.compare-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">compare</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">buf1</span>, <span class="tsd-kind-parameter">buf2</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">-1</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">0</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">1</span><a href="#compare.compare-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><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>
|
||
<pre><code class="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf1</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">from</span><span class="hl-1">(</span><span class="hl-2">'1234'</span><span class="hl-1">);</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf2</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">from</span><span class="hl-1">(</span><span class="hl-2">'0123'</span><span class="hl-1">);</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">arr</span><span class="hl-1"> = [</span><span class="hl-10">buf1</span><span class="hl-1">, </span><span class="hl-10">buf2</span><span class="hl-1">];</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">arr</span><span class="hl-1">.</span><span class="hl-0">sort</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-10">compare</span><span class="hl-1">));</span><br/><span class="hl-12">// Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]</span><br/><span class="hl-12">// (This result is equal to: [buf2, buf1].)</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">buf1</span>: <span class="tsd-signature-type">Uint8Array</span></span></li><li><span><span class="tsd-kind-parameter">buf2</span>: <span class="tsd-signature-type">Uint8Array</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">-1</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">0</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">1</span></h4><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 class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-5" class="tsd-anchor"></a>Since<a href="#Since-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v0.11.13</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:506</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="concat" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>concat</span><a href="#concat" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="concat.concat-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">concat</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">list</span>, <span class="tsd-kind-parameter">totalLength</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#concat.concat-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><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>
|
||
<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="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-12">// Create a single `Buffer` from a list of three `Buffer` instances.</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf1</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">10</span><span class="hl-1">);</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf2</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">14</span><span class="hl-1">);</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf3</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">18</span><span class="hl-1">);</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">totalLength</span><span class="hl-1"> = </span><span class="hl-10">buf1</span><span class="hl-1">.</span><span class="hl-10">length</span><span class="hl-1"> + </span><span class="hl-10">buf2</span><span class="hl-1">.</span><span class="hl-10">length</span><span class="hl-1"> + </span><span class="hl-10">buf3</span><span class="hl-1">.</span><span class="hl-10">length</span><span class="hl-1">;</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">totalLength</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: 42</span><br/><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">bufA</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">concat</span><span class="hl-1">([</span><span class="hl-10">buf1</span><span class="hl-1">, </span><span class="hl-10">buf2</span><span class="hl-1">, </span><span class="hl-10">buf3</span><span class="hl-1">], </span><span class="hl-10">totalLength</span><span class="hl-1">);</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">bufA</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: <Buffer 00 00 00 00 ...></span><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">bufA</span><span class="hl-1">.</span><span class="hl-10">length</span><span class="hl-1">);</span><br/><span class="hl-12">// Prints: 42</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
<p><code>Buffer.concat()</code> may also use the internal <code>Buffer</code> pool like <code>Buffer.allocUnsafe()</code> does.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">list</span>: <span class="tsd-signature-keyword">readonly </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol">[]</span></span><div class="tsd-comment tsd-typography"><p>List of <code>Buffer</code> or Uint8Array instances to concatenate.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">totalLength</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>Total length of the <code>Buffer</code> instances in <code>list</code> when concatenated.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-6" class="tsd-anchor"></a>Since<a href="#Since-6" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v0.7.11</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:471</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="copyBytesFrom" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>copy<wbr/>Bytes<wbr/>From</span><a href="#copyBytesFrom" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="copyBytesFrom.copyBytesFrom-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">copy<wbr/>Bytes<wbr/>From</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">view</span>, <span class="tsd-kind-parameter">offset</span><span class="tsd-signature-symbol">?</span>, <span class="tsd-kind-parameter">length</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#copyBytesFrom.copyBytesFrom-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Copies the underlying memory of <code>view</code> into a new <code>Buffer</code>.</p>
|
||
<pre><code class="js"><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">u16</span><span class="hl-1"> = </span><span class="hl-8">new</span><span class="hl-1"> </span><span class="hl-0">Uint16Array</span><span class="hl-1">([</span><span class="hl-13">0</span><span class="hl-1">, </span><span class="hl-13">0xffff</span><span class="hl-1">]);</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">copyBytesFrom</span><span class="hl-1">(</span><span class="hl-10">u16</span><span class="hl-1">, </span><span class="hl-13">1</span><span class="hl-1">, </span><span class="hl-13">1</span><span class="hl-1">);</span><br/><span class="hl-10">u16</span><span class="hl-1">[</span><span class="hl-13">1</span><span class="hl-1">] = </span><span class="hl-13">0</span><span class="hl-1">;</span><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">.</span><span class="hl-10">length</span><span class="hl-1">); </span><span class="hl-12">// 2</span><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">[</span><span class="hl-13">0</span><span class="hl-1">]); </span><span class="hl-12">// 255</span><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">buf</span><span class="hl-1">[</span><span class="hl-13">1</span><span class="hl-1">]); </span><span class="hl-12">// 255</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">view</span>: <a href="../types/_internal_.TypedArray.html" class="tsd-signature-type tsd-kind-type-alias">TypedArray</a></span><div class="tsd-comment tsd-typography"><p>The {TypedArray} to copy.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">offset</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>The starting offset within <code>view</code>.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">length</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>The number of elements from <code>view</code> to copy.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-7" class="tsd-anchor"></a>Since<a href="#Since-7" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v19.8.0</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:488</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="from" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>from</span><a href="#from" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="from.from-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">from</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">arrayBuffer</span>, <span class="tsd-kind-parameter">byteOffset</span><span class="tsd-signature-symbol">?</span>, <span class="tsd-kind-parameter">length</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#from.from-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><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>
|
||
<pre><code class="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-12">// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.</span><br/><span class="hl-8">const</span><span class="hl-1"> </span><span class="hl-11">buf</span><span class="hl-1"> = </span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">from</span><span class="hl-1">([</span><span class="hl-13">0x62</span><span class="hl-1">, </span><span class="hl-13">0x75</span><span class="hl-1">, </span><span class="hl-13">0x66</span><span class="hl-1">, </span><span class="hl-13">0x66</span><span class="hl-1">, </span><span class="hl-13">0x65</span><span class="hl-1">, </span><span class="hl-13">0x72</span><span class="hl-1">]);</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
<p>If <code>array</code> is an <code>Array</code>-like object (that is, one with a <code>length</code> property of
|
||
type <code>number</code>), it is treated as if it is an array, unless it is a <code>Buffer</code> or
|
||
a <code>Uint8Array</code>. This means all other <code>TypedArray</code> variants get treated as an <code>Array</code>. To create a <code>Buffer</code> from the bytes backing a <code>TypedArray</code>, use <code>Buffer.copyBytesFrom()</code>.</p>
|
||
<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><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">arrayBuffer</span>: <a href="../types/_internal_.WithImplicitCoercion.html" class="tsd-signature-type tsd-kind-type-alias">WithImplicitCoercion</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol"> | </span><a href="_internal_.SharedArrayBuffer.html" class="tsd-signature-type tsd-kind-interface">SharedArrayBuffer</a><span class="tsd-signature-symbol">></span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">byteOffset</span>: <span class="tsd-signature-type">number</span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">length</span>: <span class="tsd-signature-type">number</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-8" class="tsd-anchor"></a>Since<a href="#Since-8" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v5.10.0</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:333</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="from.from-2" class="tsd-anchor"></a><span class="tsd-kind-call-signature">from</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#from.from-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Creates a new Buffer using the passed {data}</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">data</span>: <span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-keyword">readonly </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></span><div class="tsd-comment tsd-typography"><p>data to create a new Buffer</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:342</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="from.from-3" class="tsd-anchor"></a><span class="tsd-kind-call-signature">from</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">data</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#from.from-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">data</span>: <a href="../types/_internal_.WithImplicitCoercion.html" class="tsd-signature-type tsd-kind-type-alias">WithImplicitCoercion</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Uint8Array</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-keyword">readonly </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">></span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:343</li></ul></aside></li><li class="tsd-signature tsd-anchor-link"><a id="from.from-4" class="tsd-anchor"></a><span class="tsd-kind-call-signature">from</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">str</span>, <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#from.from-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><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 'utf8'.</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">str</span>: <a href="../types/_internal_.WithImplicitCoercion.html" class="tsd-signature-type tsd-kind-type-alias">WithImplicitCoercion</a><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-symbol">{ </span><br/><span> </span><span class="tsd-kind-call-signature">[toPrimitive]</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">hint</span><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">string</span><span class="tsd-signature-symbol">; </span><br/><span class="tsd-signature-symbol">}</span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">encoding</span>: <a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:349</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="isBuffer" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>is<wbr/>Buffer</span><a href="#isBuffer" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="isBuffer.isBuffer-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">is<wbr/>Buffer</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">obj</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-kind-parameter">obj</span><span class="tsd-signature-keyword"> is </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#isBuffer.isBuffer-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns <code>true</code> if <code>obj</code> is a <code>Buffer</code>, <code>false</code> otherwise.</p>
|
||
<pre><code class="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isBuffer</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">alloc</span><span class="hl-1">(</span><span class="hl-13">10</span><span class="hl-1">)); </span><span class="hl-12">// true</span><br/><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isBuffer</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">from</span><span class="hl-1">(</span><span class="hl-2">'foo'</span><span class="hl-1">)); </span><span class="hl-12">// true</span><br/><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isBuffer</span><span class="hl-1">(</span><span class="hl-2">'a string'</span><span class="hl-1">); </span><span class="hl-12">// false</span><br/><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isBuffer</span><span class="hl-1">([]); </span><span class="hl-12">// false</span><br/><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isBuffer</span><span class="hl-1">(</span><span class="hl-8">new</span><span class="hl-1"> </span><span class="hl-0">Uint8Array</span><span class="hl-1">(</span><span class="hl-13">1024</span><span class="hl-1">)); </span><span class="hl-12">// false</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">obj</span>: <span class="tsd-signature-type">any</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-kind-parameter">obj</span><span class="tsd-signature-keyword"> is </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-9" class="tsd-anchor"></a>Since<a href="#Since-9" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v0.1.101</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:376</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="isEncoding" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>is<wbr/>Encoding</span><a href="#isEncoding" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="isEncoding.isEncoding-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">is<wbr/>Encoding</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-keyword"> is </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a><a href="#isEncoding.isEncoding-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns <code>true</code> if <code>encoding</code> is the name of a supported character encoding,
|
||
or <code>false</code> otherwise.</p>
|
||
<pre><code class="js"><span class="hl-9">import</span><span class="hl-1"> { </span><span class="hl-10">Buffer</span><span class="hl-1"> } </span><span class="hl-9">from</span><span class="hl-1"> </span><span class="hl-2">'node:buffer'</span><span class="hl-1">;</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isEncoding</span><span class="hl-1">(</span><span class="hl-2">'utf8'</span><span class="hl-1">));</span><br/><span class="hl-12">// Prints: true</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isEncoding</span><span class="hl-1">(</span><span class="hl-2">'hex'</span><span class="hl-1">));</span><br/><span class="hl-12">// Prints: true</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isEncoding</span><span class="hl-1">(</span><span class="hl-2">'utf/8'</span><span class="hl-1">));</span><br/><span class="hl-12">// Prints: false</span><br/><br/><span class="hl-10">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-10">Buffer</span><span class="hl-1">.</span><span class="hl-0">isEncoding</span><span class="hl-1">(</span><span class="hl-2">''</span><span class="hl-1">));</span><br/><span class="hl-12">// Prints: false</span>
|
||
</code><button type="button">Copy</button></pre>
|
||
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">encoding</span>: <span class="tsd-signature-type">string</span></span><div class="tsd-comment tsd-typography"><p>A character encoding name to check.</p>
|
||
</div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-kind-parameter">encoding</span><span class="tsd-signature-keyword"> is </span><a href="../types/_internal_.BufferEncoding.html" class="tsd-signature-type tsd-kind-type-alias">BufferEncoding</a></h4><div class="tsd-comment tsd-typography"><h4 class="tsd-anchor-link"><a id="Since-10" class="tsd-anchor"></a>Since<a href="#Since-10" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>v0.9.1</p>
|
||
</div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:399</li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-external"><a id="of" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>of</span><a href="#of" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="of.of-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">of</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">items</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a><a href="#of.of-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Creates a new Buffer using the passed {data}</p>
|
||
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><code class="tsd-tag">Rest</code><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">items</span>: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="_internal_.Buffer.html" class="tsd-signature-type tsd-kind-interface">Buffer</a></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/buffer.d.ts:361</li></ul></aside></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#poolSize" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>pool<wbr/>Size</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="tsd-otp-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#alloc" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>alloc</span></a><a href="#allocUnsafe" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>alloc<wbr/>Unsafe</span></a><a href="#allocUnsafeSlow" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>alloc<wbr/>Unsafe<wbr/>Slow</span></a><a href="#byteLength" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>byte<wbr/>Length</span></a><a href="#compare" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>compare</span></a><a href="#concat" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>concat</span></a><a href="#copyBytesFrom" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>copy<wbr/>Bytes<wbr/>From</span></a><a href="#from" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>from</span></a><a href="#isBuffer" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>is<wbr/>Buffer</span></a><a href="#isEncoding" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>is<wbr/>Encoding</span></a><a href="#of" class="tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>of</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>liquidjs</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|