| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9c7a2e3 commit 93e91f3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2965,7 +2965,7 @@ function readableByteStreamControllerRespondWithNewView(controller, view) { | |||
| 2965 | 2965 | if (byteOffset + bytesFilled !== viewByteOffset) | |
| 2966 | 2966 | throw new ERR_INVALID_ARG_VALUE.RangeError('view', view); | |
| 2967 | 2967 | ||
| 2968 | - if (bytesFilled + viewByteOffset > byteLength) | ||
| 2968 | + if (bytesFilled + viewByteLength > byteLength) | ||
| 2969 | 2969 | throw new ERR_INVALID_ARG_VALUE.RangeError('view', view); | |
| 2970 | 2970 | ||
| 2971 | 2971 | if (bufferByteLength !== viewBufferByteLength) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1657,3 +1657,33 @@ class Source { | |||
| 1657 | 1657 | reader.read(new DataView(buffer)) | |
| 1658 | 1658 | .then(common.mustCall()); | |
| 1659 | 1659 | } | |
| 1660 | + | ||
| 1661 | + { | ||
| 1662 | + const stream = new ReadableStream({ | ||
| 1663 | + type: 'bytes', | ||
| 1664 | + autoAllocateChunkSize: 128, | ||
| 1665 | + pull: common.mustCall((controller) => { | ||
| 1666 | + const view = controller.byobRequest.view; | ||
| 1667 | + const dest = new Uint8Array( | ||
| 1668 | + view.buffer, | ||
| 1669 | + view.byteOffset, | ||
| 1670 | + view.byteLength | ||
| 1671 | + ); | ||
| 1672 | + dest.fill(1); | ||
| 1673 | + controller.byobRequest.respondWithNewView(dest); | ||
| 1674 | + }), | ||
| 1675 | + }); | ||
| 1676 | + | ||
| 1677 | + const reader = stream.getReader({ mode: 'byob' }); | ||
| 1678 | + | ||
| 1679 | + const buffer = new ArrayBuffer(10); | ||
| 1680 | + const view = new Uint8Array( | ||
| 1681 | + buffer, | ||
| 1682 | + 1, | ||
| 1683 | + 3 | ||
| 1684 | + ); | ||
| 1685 | + | ||
| 1686 | + reader.read(view).then(common.mustCall(({ value }) => { | ||
| 1687 | + assert.deepStrictEqual(value, new Uint8Array([1, 1, 1])); | ||
| 1688 | + })); | ||
| 1689 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments