diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 4f28095a927970..1bfd30b1943e42 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -862,31 +862,6 @@ console.log(buf2.toString()); A `TypeError` will be thrown if `buffer` is not a `Buffer`. -### Class Method: Buffer.from(string[, encoding]) - - -* `string` {string} A string to encode. -* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`. - -Creates a new `Buffer` containing `string`. The `encoding` parameter identifies -the character encoding of `string`. - -```js -const buf1 = Buffer.from('this is a tést'); -const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex'); - -console.log(buf1.toString()); -// Prints: this is a tést -console.log(buf2.toString()); -// Prints: this is a tést -console.log(buf1.toString('ascii')); -// Prints: this is a tC)st -``` - -A `TypeError` will be thrown if `string` is not a string. - ### Class Method: Buffer.from(object[, offsetOrEncoding[, length]]) + +* `string` {string} A string to encode. +* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`. + +Creates a new `Buffer` containing `string`. The `encoding` parameter identifies +the character encoding of `string`. + +```js +const buf1 = Buffer.from('this is a tést'); +const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex'); + +console.log(buf1.toString()); +// Prints: this is a tést +console.log(buf2.toString()); +// Prints: this is a tést +console.log(buf1.toString('ascii')); +// Prints: this is a tC)st +``` + +A `TypeError` will be thrown if `string` is not a string. + ### Class Method: Buffer.isBuffer(obj)