Re: [whatwg/streams] Always transfer given ArrayBuffer in ReadableByteStreamControllerPullInto (#753)

tschneidereit commented on this pull request.

Yeah, this makes sense. I think we might eventually want to actually transfer the buffer, but until such a time, this hack is a good solution. (I can't approve this because it's my own PR, but r+)

> @@ -101,7 +101,19 @@ exports.PromiseInvokeOrPerformFallback = (O, P, args, F, argsF) => {
 };
 
 // Not implemented correctly
-exports.TransferArrayBuffer = O => O.slice();
+exports.TransferArrayBuffer = O => {
+  const transferredIshVersion = O.slice();
+
+  // This is specifically to fool tests that test "is transferred" by taking a non-zero-length
+  // ArrayBuffer and checking if its byteLength starts returning 0.
+  Object.defineProperty(O, "byteLength", {
+    get() {
+      return 0;
+    }
+  });

I think I'm a bit in awe with this hack :)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/753#pullrequestreview-62995704

Received on Friday, 15 September 2017 09:54:04 UTC