June 2014
Intermediate to advanced
696 pages
38h 52m
English
Buffer objects are actually raw memory allocations. Therefore, you must determine their sizes when you create them. There are three methods for creating Buffer objects using the new keyword:
new Buffer(sizeInBytes)new Buffer(octetArray)new Buffer(string, [encoding])
For example, the following lines of code define buffers using a byte size, an octet buffer, and a UTF8 string:
var buf256 = new Buffer(256);var bufOctets = new Buffer([0x6f, 0x63, 0x74, 0x65, 0x74, 0x73]);var bufUTF8 = new Buffer("Some UTF8 Text \u00b6 \u30c6 \u20ac", 'utf8');
Read now
Unlock full access