Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
Buffer Memory Pools
node v10.24.1
version:
master
endpoint
share
tweet
const buffer = Buffer.from([1,2,3])
buffer.length
buffer.buffer.byteLength
buffer.byteOffset
Buffer.poolSize
const largeBuffer = Buffer.allocUnsafe(4096).fill('a')
largeBuffer.buffer.byteLength
const largeBufferAlloc = Buffer.alloc(20, 'a') largeBufferAlloc.buffer.byteLength
const largeBufferAllocUnsafe = Buffer.allocUnsafe(20).fill('a') largeBufferAllocUnsafe.buffer.byteLength
const bufferFromSmallString = Buffer.from('Short...') bufferFromSmallString.buffer.byteLength
const bufferFromRegularArray = Buffer.from([1,2,3]) bufferFromSmallString.buffer.byteLength
const uint8Array = new Uint8Array({length: 5}) const bufferFromUint8Array = Buffer.from(uint8Array) bufferFromUint8Array.buffer.byteLength
const bufferFromArrayBuffer = Buffer.from(uint8Array.buffer) bufferFromArrayBuffer.buffer.byteLength
console.log(uint8Array.buffer === bufferFromArrayBuffer.buffer) console.log(uint8Array.buffer === bufferFromUint8Array.buffer)
Loading…
no comments
sign in
to comment