Menu
×

Được chứng nhận

Ghi lại kiến ​​thức của bạn

Đăng nhập Đăng ký

Tạo Tài khoản Example.com.vn miễn phí để cải thiện trải nghiệm học tập của bạn

Người tìm đường và việc học của tôi

Theo dõi tiến độ học tập của bạn tại Example.com.vn và thu thập phần thưởng

Nâng cấp

Trở thành người dùng PLUS và mở khóa các tính năng mạnh mẽ (không có quảng cáo, lưu trữ, hỗ trợ, ..)

Bắt đầu từ đâu

Bạn không chắc chắn muốn bắt đầu từ đâu? Đi theo con đường được hướng dẫn của chúng tôi

Trình chỉnh sửa mã (Dùng thử)

Với trình chỉnh sửa mã trực tuyến của chúng tôi, bạn có thể chỉnh sửa mã và xem kết quả trong trình duyệt của mình

Video

Tìm hiểu những điều cơ bản về HTML qua video hướng dẫn thú vị và hấp dẫn

Mẫu

Chúng tôi đã tạo một loạt mẫu trang web đáp ứng mà bạn có thể sử dụng - miễn phí!

Web hosting

Lưu trữ trang web của riêng bạn và chia sẻ nó với mọi người với Example.com.vn Spaces

Tạo một máy chủ

Tạo máy chủ của riêng bạn bằng Python, PHP, React.js, Node.js, Java, C#, v.v.

Làm thế nào để

Bộ sưu tập lớn các đoạn mã cho HTML, CSS và JavaScript

Khung CSS

Xây dựng các trang web nhanh và phản hồi nhanh bằng cách sử dụng khung W3.CSS miễn phí của chúng tôi

Thống kê trình duyệt

Đọc xu hướng dài hạn của việc sử dụng trình duyệt

Tốc độ gõ

Kiểm tra tốc độ đánh máy của bạn

Đào tạo AWS

Tìm hiểu dịch vụ web của Amazon

Bộ chọn màu

Sử dụng công cụ chọn màu của chúng tôi để tìm các màu RGB, HEX và HSL khác nhau. Bánh xe màu hình tròn thể hiện sự chuyển màu trong quang phổ

Trò chơi mã

Trò chơi mã hóa W3Schools! Giúp linh miêu thu thập nón thông Logo Lynx

Đặt mục tiêu

Nhận hành trình học tập được cá nhân hóa dựa trên các kỹ năng và mục tiêu hiện tại của bạn

Bản tin

Tham gia bản tin của chúng tôi và có quyền truy cập vào nội dung độc quyền mỗi tháng

Việc làm

Thuê những tài năng công nghệ hàng đầu. Hợp lý hóa quy trình tuyển dụng của bạn để có đội ngũ phù hợp hoàn hảo

Lớp học

Hãy liên hệ để sử dụng Example.com.vn Plus và các chứng chỉ với tư cách là một tổ chức giáo dục

×
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP CÁCH W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS AN NINH MẠNG DỮ LIỆU KHOA HỌC

Mô-đun bộ đệm Node.js

❮ Mô-đun tích hợp


Ví dụ

Chuyển đổi chuỗi "abc" thành luồng dữ liệu nhị phân:

var buf = Buffer.from('abc');
console.log(buf);
Chạy ví dụ »

Định nghĩa và cách sử dụng

Mô-đun bộ đệm cung cấp cách xử lý các luồng dữ liệu nhị phân.

Đối tượng Buffer là một đối tượng toàn cục trong Node.js và không cần thiết phải nhập nó bằng từ khóa require .


Cú pháp

Cú pháp tạo Bộ đệm trống có độ dài 15:

var buf = Buffer.alloc(15);

Thuộc tính và phương thức đệm

Method Description
alloc() Creates a Buffer object of the specified length
allocUnsafe() Creates a non-zero-filled Buffer of the specified length
allocUnsafeSlow Creates a non-zero-filled and non-pooled Buffer of the specified length
byteLength() Returns the numbers of bytes in a specified object
compare() Compares two Buffer objects
concat() Concatenates an array of Buffer objects into one Buffer object
copy() Copies the specified number of bytes of a Buffer object
entries() Returns an iterator of "index" "byte" pairs of a Buffer object
equals() Compares two Buffer objects, and returns true if it is a match, otherwise false
fill() Fills a Buffer object with the specified values
from() Creates a Buffer object from an object (string/array/buffer)
includes() Checks if the Buffer object contains the specified value. Returns true if there is a match, otherwise false
indexOf() Checks if the Buffer object contains the specified value. Returns the first occurrence, otherwise -1
isBuffer() Checks if an object is a Buffer object
isEncoding() Checks if the Buffer object supports the specified encoding
keys() Returns an array of keys in a Buffer object
lastIndexOf() Checks if the Buffer object contains the specified value. Returns the first occurrence, starting from the end, otherwise -1
length Returns the length of a Buffer object, in bytes
poolSize Sets or returns the number of bytes used for pooling
readDoubleBE() Reads a 64 bit double from a Buffer object, returns the result in big endian
readDoubleLE() Reads a 64 bit double from a Buffer object, returns the result in little endian
readFloatBE() Reads a 32 bit float from a Buffer object, returns the result in big endian
readFloatLE() Reads a 32 bit float from a Buffer object, returns the result in little endian
readInt8() Reads a 8 bit integer from a Buffer object
readInt16BE() Reads a 16 bit integer from a Buffer object, returns the result in big endian
readInt16LE() Reads a 16 bit integer from a Buffer object, returns the result in little endian
readInt32BE() Reads a 32 bit integer from a Buffer object, returns the result in big endian
readInt32LE() Reads a 32 bit integer from a Buffer object, returns the result in little endian
readIntBE() Reads the specified number of bytes from a Buffer object, returns the result in big endian
readIntLE() Reads the specified number of bytes from a Buffer object, returns the result in little endian
readUInt8() Reads an unsigned 8 bit integer from a Buffer object
readUInt16BE() Reads an unsigned 16 bit integer from a Buffer object, returns the result in big endian
readUInt16LE() Reads an unsigned 16 bit integer from a Buffer object, returns the result in little endian
readUInt32BE() Reads an unsigned 32 bit integer from a Buffer object, returns the result in big endian
readUInt32LE() Reads an unsigned 32 bit integer from a Buffer object, returns the result in little endian
readUintBE() Reads the specified number of bytes from a Buffer object, returns the result as an unsigned integer
readUIntLE() Reads the specified number of bytes from a Buffer object, returns the result as an unsigned integer
slice() Slices a Buffer object into a new Buffer objects starting and ending at the specified positions
swap16() Swaps the byte-order of a 16 bit Buffer object
swap32() Swaps the byte-order of a 32 bit Buffer object
swap64() Swaps the byte-order of a 64 bit Buffer object
toString() Returns a string version of a Buffer object
toJSON() Returns a JSON version of a Buffer object
values() Returns an array of values in a Buffer object
write() Writes a specified string to a Buffer object
writeDoubleBE() Writes the specified bytes, using big endian, to a Buffer object. The bytes should be 64 bit double.
writeDoubleLE() Writes the specified bytes, using little endian, to a Buffer object. The bytes should be 64 bit double.
writeFloatBE() Writes the specified bytes, using big endian, to a Buffer object. The bytes should be 32 bit float.
writeFloatLE() Writes the specified bytes, using little endian, to a Buffer object. The bytes should be 32 bit float.
writeInt8() Writes the specified bytes to a Buffer object. The bytes should be 8 bit integer
writeInt16BE() Writes the specified bytes, using big endian, to a Buffer object. The bytes should be 16 bit integer.
writeInt16LE() Writes the specified bytes, using little endian, to a Buffer object. The bytes should be 16 bit integer.
writeInt32BE() Writes the specified bytes, using big endian, to a Buffer object. The bytes should be 32 bit integer.
writeInt32LE() Writes the specified bytes, using little endian, to a Buffer object. The bytes should be 32 bit integer.
writeIntBE() Writes the specified bytes, using big endian, to a Buffer object.
writeIntLE() Writes the specified bytes, using little endian, to a Buffer object.
writeUInt8() Writes the specified bytes to a Buffer object. The bytes should be 8 bit unsigned integer
writeUInt16BE() Writes the specified bytes, using big endian, to a Buffer object. The bytes should be 16 bit unsigned integer.
writeUInt16LE() Writes the specified bytes, using little endian, to a Buffer object. The bytes should be 16 bit unsigned integer.
writeUInt32BE() Writes the specified bytes, using big endian, to a Buffer object. The bytes should be 32 bit unsigned integer.
writeUInt32LE() Writes the specified bytes, using little endian, to a Buffer object. The bytes should be 32 bit unsigned integer.
writeUIntBE() Writes the specified bytes, using big endian, to a Buffer object
writeUIntLE() Writes the specified bytes, using little endian, to a Buffer object

❮ Mô-đun tích hợp

×

Liên hệ bán hàng

Nếu bạn muốn sử dụng dịch vụ của Example.com.vn với tư cách là một tổ chức giáo dục, nhóm hoặc doanh nghiệp, hãy gửi email cho chúng tôi:
[email được bảo vệ]

Báo cáo lỗi

Nếu bạn muốn báo cáo lỗi hoặc nếu bạn muốn đưa ra đề xuất, hãy gửi email cho chúng tôi:
[email được bảo vệ]

Example.com.vn được tối ưu hóa cho việc học tập và đào tạo. Các ví dụ có thể được đơn giản hóa để cải thiện khả năng đọc và học. Các hướng dẫn, tài liệu tham khảo và ví dụ liên tục được xem xét để tránh sai sót, nhưng chúng tôi không thể đảm bảo tính chính xác hoàn toàn của mọi nội dung. Trong khi sử dụng W3Schools, bạn đồng ý đã đọc và chấp nhận các điều khoản sử dụng , chính sách cookie và quyền riêng tư của chúng tôi.

Bản quyền 1999-2024 của Refsnes Data. Đã đăng ký Bản quyền. Example.com.vn được cung cấp bởi W3.CSS .