new from(data, encodingopt, lengthopt) → {_buf}
[W.I.P] Returns a new Buffer. Similar to Node.js Buffer.from().
Example
var buf = Buffer.from('012345XYZ');
console.log(buf.toString('utf8')); // 012345XYZ
console.log(buf.toString('base64')); // MDEyMzQ1WFla
console.log(buf.toString('hex')); // 30313233343558595a
console.log(buf.values()); // <Buffer 30 31 32 32 ....>
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
any | ||
encoding |
string |
<optional> |
If data is String, the encoding of string. Default: 'utf8'. |
length |
number |
<optional> |
Returns:
- Type
- _buf