From: rafael Date: Tue, 13 Aug 2013 07:10:36 +0000 (+0200) Subject: limited slicing implementation X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=8cf26fd2a12c6c23e558955bdbff6bece92d593d;p=buffer.git limited slicing implementation --- diff --git a/index.js b/index.js index 7d95278..1875afc 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,11 @@ function Buffer(subject, encoding, offset) { // Are we slicing? if (typeof offset === 'number') { this.length = coerce(encoding); - this.offset = offset; + // slicing works, with limitations (no parent tracking/update) + // check https://github.com/toots/buffer-browserify/issues/19 + for (var i = 0; i < this.length; i++) { + this[i] = subject.get(i+offset); + } } else { // Find the length switch (type = typeof subject) {