Re: [whatwg/streams] Fix queue total size tracking logic (#661)

isonmad commented on this pull request.



> @@ -2,39 +2,43 @@
 const assert = require('assert');
 const { IsFiniteNonNegativeNumber } = require('./helpers.js');
 
-exports.DequeueValue = queue => {
-  assert(queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
-  const pair = queue.shift();
+exports.DequeueValue = container => {
+  assert('_queue' in container && '_queueTotalSize' in container,
+    'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');

Copypasted assert text.

>  
   return pair.value;
 };
 
-exports.EnqueueValueWithSize = (queue, value, size) => {
+exports.EnqueueValueWithSize = (container, value, size) => {
+  assert('_queue' in container && '_queueTotalSize' in container,
+    'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');

Same here.

>  };
 
-// This implementation is not per-spec. Total size is cached for speed.
-exports.GetTotalQueueSize = queue => {
-  if (queue._totalSize === undefined) {
-    queue._totalSize = 0;
-  }
-  return queue._totalSize;
-};
+exports.PeekQueueValue = container => {
+  assert('_queue' in container && '_queueTotalSize' in container,
+    'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');

Same here.

-- 
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/661#pullrequestreview-17557094

Received on Thursday, 19 January 2017 21:07:22 UTC