What is a buffer in Node.js?

后端 未结 3 1131
离开以前
离开以前 2021-02-02 06:34

As you can read in the Node.js documentation on the Buffer class, a buffer

is similar to an array of integers but corresponds to a raw memory allocation o

3条回答
  •  眼角桃花
    2021-02-02 07:31

    A Buffer is a chunk of memory, just like you would have it in C/C++. You can interpret this memory as an array of integer or floating point numbers of various lengths, or as a binary string. Unlike higher-level data structures like arrays, a buffer is not resizable.

    It corresponds roughly to:

    • char* or char[] in C/C++
    • byte[] in Java
    • A mutable bytes or a non-resizable bytearray in Python
    • Strings in php if they were mutable

提交回复
热议问题