Node.js--buffer

Source: Internet
Author: User

Introduced

    • JavaScript does not have a mechanism to read and manipulate binary data streams, but node. JS introduces a buffer type that can manipulate TCP streams or file streams
    • Buffer can be used to store temporary data (binary data), when we transfer a large chunk of data from one place to another can be transmitted through the buffer object, each time only a small piece of transmission, until the data transfer is complete
    • The buffer object is similar to an array of shapes, but the size is fixed, the size is determined at the time it was created, it can no longer be changed, and the physical memory is allocated outside the V8 heap
    • The buffer object is global, so require references are not required

Common APIs

    • Buffer.from () Creating an instance object
    • Buffer.concat (List[,totallength]) splicing multiple buffer objects as an object
    • Buffer.bytelength (string[,encoding]) gets the character for the byte length
    • Buffer.isbuffer (obj) determines whether the buffer object
    • Buf[index] Gets the value of the corresponding index in the buffer object
    • Buf.length getting the Buffer object length

Obsolete API

    • New Buffer (Array)
    • New buffer (buffer)
    • New Buffer (Arraybuffer[,byteoffset[,length])
    • New Buffer (string[,encoding])

Coding

    • Ascii
    • Utf8
    • Utf16le (UCS2 is UTF16 alias)
    • Base64
    • Latin1 (binary is latin1 alias)
    • Hex (with two-bit 16 binary to represent each byte)

Stream

    • Writable. Stream
    • Readable. Stream

Node.js--buffer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.