June 2014
Intermediate to advanced
696 pages
38h 52m
English
There are several methods for reading from buffers. The simplest is to use the toString() method to convert all or part of a buffer to a string. However, you can also access specific indexes in the buffer directly or by using read(). Also, Node.js provides a StringDecoder object that has a write(buffer) method that decodes and writes buffered data using the specified encoding. Table 5.3 describes these methods for reading Buffer objects.
Table 5.3 Methods of reading to Buffer objects
To illustrate reading from buffers, the code in Listing 5.2 defines a buffer with UTF8 encoded characters and then uses toString() without parameters ...
Read now
Unlock full access