From: Feross Aboukhadijeh Date: Tue, 12 Jan 2016 23:24:18 +0000 (+0100) Subject: update readme X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=cc4f496634270c13f6db09fbe7a761aae2204343;p=buffer.git update readme --- 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)) {