doc: use destructuring in code examples

PR-URL: https://github.com/nodejs/node/pull/13349
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Vse Mozhet Byt
2017-06-01 01:21:22 +03:00
parent 78b135806f
commit 7de6998d89
8 changed files with 49 additions and 49 deletions

View File

@@ -7,13 +7,13 @@ strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
characters. It can be accessed using:
```js
const StringDecoder = require('string_decoder').StringDecoder;
const { StringDecoder } = require('string_decoder');
```
The following example shows the basic use of the `StringDecoder` class.
```js
const StringDecoder = require('string_decoder').StringDecoder;
const { StringDecoder } = require('string_decoder');
const decoder = new StringDecoder('utf8');
const cent = Buffer.from([0xC2, 0xA2]);
@@ -32,7 +32,7 @@ In the following example, the three UTF-8 encoded bytes of the European Euro
symbol (`€`) are written over three separate operations:
```js
const StringDecoder = require('string_decoder').StringDecoder;
const { StringDecoder } = require('string_decoder');
const decoder = new StringDecoder('utf8');
decoder.write(Buffer.from([0xE2]));