From cc4f496634270c13f6db09fbe7a761aae2204343 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 13 Jan 2016 00:24:18 +0100 Subject: [PATCH] update readme --- README.md | 9 +++++++-- index.js | 15 ++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d061cc7..df1ca47 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,13 @@ instead of the **node.js core** module named `buffer`! ## how does it work? -`Buffer` is a subclass of `Uint8Array` augmented with all the `Buffer` API methods. -The `Uint8Array` prototype is not modified. +The Buffer constructor returns instances of `Uint8Array` that have their prototype +changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`, +so the returned instances will have all the node `Buffer` methods and the +`Uint8Array` methods. Square bracket notation works as expected -- it returns a +single octet. + +The `Uint8Array` prototype remains unmodified. ## one minor difference diff --git a/index.js b/index.js index 1d22868..15d7c50 100644 --- a/index.js +++ b/index.js @@ -66,16 +66,13 @@ function kMaxLength () { } /** - * Class: Buffer - * ============= + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. + * The `Uint8Array` prototype remains unmodified. */ function Buffer (arg) { if (!(this instanceof Buffer)) { -- 2.34.1