mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
doc: use Buffer.from() instead of new Buffer()
Use new API of Buffer to developers in most documents. PR-URL: https://github.com/nodejs/node/pull/6367 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
This commit is contained in:
1 parent
cbbe95e1e1
commit
19fb1345ba
7 files changed
+13
-13
No files matched your search
@@ -10,10 +10,10 @@ additional support for utf8.
|
||||
const StringDecoder = require('string_decoder').StringDecoder;
|
||||
const decoder = new StringDecoder('utf8');
|
||||
|
||||
const cent = new Buffer([0xC2, 0xA2]);
|
||||
const cent = Buffer.from([0xC2, 0xA2]);
|
||||
console.log(decoder.write(cent));
|
||||
|
||||
const euro = new Buffer([0xE2, 0x82, 0xAC]);
|
||||
const euro = Buffer.from([0xE2, 0x82, 0xAC]);
|
||||
console.log(decoder.write(euro));
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user