Best JavaScript code snippet using wpt
readable-stream.js
Source:readable-stream.js
...483 this._readRequests = [];484 }485 get closed() {486 if (IsReadableStreamDefaultReader(this) === false) {487 return Promise.reject(defaultReaderBrandCheckException('closed'));488 }489 return this._closedPromise;490 }491 cancel(reason) {492 if (IsReadableStreamDefaultReader(this) === false) {493 return Promise.reject(defaultReaderBrandCheckException('cancel'));494 }495 if (this._ownerReadableStream === undefined) {496 return Promise.reject(readerLockException('cancel'));497 }498 return ReadableStreamReaderGenericCancel(this, reason);499 }500 read() {501 if (IsReadableStreamDefaultReader(this) === false) {502 return Promise.reject(defaultReaderBrandCheckException('read'));503 }504 if (this._ownerReadableStream === undefined) {505 return Promise.reject(readerLockException('read from'));506 }507 return ReadableStreamDefaultReaderRead(this);508 }509 releaseLock() {510 if (IsReadableStreamDefaultReader(this) === false) {511 throw defaultReaderBrandCheckException('releaseLock');512 }513 if (this._ownerReadableStream === undefined) {514 return;515 }516 if (this._readRequests.length > 0) {517 throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');518 }519 ReadableStreamReaderGenericRelease(this);520 }521}522class ReadableStreamBYOBReader {523 constructor(stream) {524 if (!IsReadableStream(stream)) {525 throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' +526 'byte source');527 }528 if (IsReadableByteStreamController(stream._readableStreamController) === false) {529 throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' +530 'source');531 }532 if (IsReadableStreamLocked(stream)) {533 throw new TypeError('This stream has already been locked for exclusive reading by another reader');534 }535 ReadableStreamReaderGenericInitialize(this, stream);536 this._readIntoRequests = [];537 }538 get closed() {539 if (!IsReadableStreamBYOBReader(this)) {540 return Promise.reject(byobReaderBrandCheckException('closed'));541 }542 return this._closedPromise;543 }544 cancel(reason) {545 if (!IsReadableStreamBYOBReader(this)) {546 return Promise.reject(byobReaderBrandCheckException('cancel'));547 }548 if (this._ownerReadableStream === undefined) {549 return Promise.reject(readerLockException('cancel'));550 }551 return ReadableStreamReaderGenericCancel(this, reason);552 }553 read(view) {554 if (!IsReadableStreamBYOBReader(this)) {555 return Promise.reject(byobReaderBrandCheckException('read'));556 }557 if (this._ownerReadableStream === undefined) {558 return Promise.reject(readerLockException('read from'));559 }560 if (!ArrayBuffer.isView(view)) {561 return Promise.reject(new TypeError('view must be an array buffer view'));562 }563 if (view.byteLength === 0) {564 return Promise.reject(new TypeError('view must have non-zero byteLength'));565 }566 return ReadableStreamBYOBReaderRead(this, view);567 }568 releaseLock() {569 if (!IsReadableStreamBYOBReader(this)) {570 throw byobReaderBrandCheckException('releaseLock');571 }572 if (this._ownerReadableStream === undefined) {573 return;574 }575 if (this._readIntoRequests.length > 0) {576 throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');577 }578 ReadableStreamReaderGenericRelease(this);579 }580}581// Abstract operations for the readers.582function IsReadableStreamBYOBReader(x) {583 if (!typeIsObject(x)) {584 return false;585 }586 if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {587 return false;588 }589 return true;590}591function IsReadableStreamDefaultReader(x) {592 if (!typeIsObject(x)) {593 return false;594 }595 if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {596 return false;597 }598 return true;599}600function ReadableStreamReaderGenericInitialize(reader, stream) {601 reader._ownerReadableStream = stream;602 stream._reader = reader;603 if (stream._state === 'readable') {604 defaultReaderClosedPromiseInitialize(reader);605 } else if (stream._state === 'closed') {606 defaultReaderClosedPromiseInitializeAsResolved(reader);607 } else {608 assert(stream._state === 'errored', 'state must be errored');609 defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);610 reader._closedPromise.catch(() => {});611 }612}613// A client of ReadableStreamDefaultReader and ReadableStreamBYOBReader may use these functions directly to bypass state614// check.615function ReadableStreamReaderGenericCancel(reader, reason) {616 const stream = reader._ownerReadableStream;617 assert(stream !== undefined);618 return ReadableStreamCancel(stream, reason);619}620function ReadableStreamReaderGenericRelease(reader) {621 assert(reader._ownerReadableStream !== undefined);622 assert(reader._ownerReadableStream._reader === reader);623 if (reader._ownerReadableStream._state === 'readable') {624 defaultReaderClosedPromiseReject(625 reader,626 new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));627 } else {628 defaultReaderClosedPromiseResetToRejected(629 reader,630 new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));631 }632 reader._closedPromise.catch(() => {});633 reader._ownerReadableStream._reader = undefined;634 reader._ownerReadableStream = undefined;635}636function ReadableStreamBYOBReaderRead(reader, view) {637 const stream = reader._ownerReadableStream;638 assert(stream !== undefined);639 stream._disturbed = true;640 if (stream._state === 'errored') {641 return Promise.reject(stream._storedError);642 }643 // Controllers must implement this.644 return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);645}646function ReadableStreamDefaultReaderRead(reader) {647 const stream = reader._ownerReadableStream;648 assert(stream !== undefined);649 stream._disturbed = true;650 if (stream._state === 'closed') {651 return Promise.resolve(CreateIterResultObject(undefined, true));652 }653 if (stream._state === 'errored') {654 return Promise.reject(stream._storedError);655 }656 assert(stream._state === 'readable');657 return stream._readableStreamController[InternalPull]();658}659// Controllers660class ReadableStreamDefaultController {661 constructor(stream, underlyingSource, size, highWaterMark) {662 if (IsReadableStream(stream) === false) {663 throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');664 }665 if (stream._readableStreamController !== undefined) {666 throw new TypeError(667 'ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');668 }669 this._controlledReadableStream = stream;670 this._underlyingSource = underlyingSource;671 this._queue = [];672 this._started = false;673 this._closeRequested = false;674 this._pullAgain = false;675 this._pulling = false;676 const normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);677 this._strategySize = normalizedStrategy.size;678 this._strategyHWM = normalizedStrategy.highWaterMark;679 const controller = this;680 const startResult = InvokeOrNoop(underlyingSource, 'start', [this]);681 Promise.resolve(startResult).then(682 () => {683 controller._started = true;684 assert(controller._pulling === false);685 assert(controller._pullAgain === false);686 ReadableStreamDefaultControllerCallPullIfNeeded(controller);687 },688 r => {689 ReadableStreamDefaultControllerErrorIfNeeded(controller, r);690 }691 )692 .catch(rethrowAssertionErrorRejection);693 }694 get desiredSize() {695 if (IsReadableStreamDefaultController(this) === false) {696 throw defaultControllerBrandCheckException('desiredSize');697 }698 return ReadableStreamDefaultControllerGetDesiredSize(this);699 }700 close() {701 if (IsReadableStreamDefaultController(this) === false) {702 throw defaultControllerBrandCheckException('close');703 }704 if (this._closeRequested === true) {705 throw new TypeError('The stream has already been closed; do not close it again!');706 }707 const state = this._controlledReadableStream._state;708 if (state !== 'readable') {709 throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be closed`);710 }711 ReadableStreamDefaultControllerClose(this);712 }713 enqueue(chunk) {714 if (IsReadableStreamDefaultController(this) === false) {715 throw defaultControllerBrandCheckException('enqueue');716 }717 if (this._closeRequested === true) {718 throw new TypeError('stream is closed or draining');719 }720 const state = this._controlledReadableStream._state;721 if (state !== 'readable') {722 throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be enqueued to`);723 }724 return ReadableStreamDefaultControllerEnqueue(this, chunk);725 }726 error(e) {727 if (IsReadableStreamDefaultController(this) === false) {728 throw defaultControllerBrandCheckException('error');729 }730 const stream = this._controlledReadableStream;731 if (stream._state !== 'readable') {732 throw new TypeError(`The stream is ${stream._state} and so cannot be errored`);733 }734 ReadableStreamDefaultControllerError(this, e);735 }736 [InternalCancel](reason) {737 this._queue = [];738 return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);739 }740 [InternalPull]() {741 const stream = this._controlledReadableStream;742 if (this._queue.length > 0) {743 const chunk = DequeueValue(this._queue);744 if (this._closeRequested === true && this._queue.length === 0) {745 ReadableStreamClose(stream);746 } else {747 ReadableStreamDefaultControllerCallPullIfNeeded(this);748 }749 return Promise.resolve(CreateIterResultObject(chunk, false));750 }751 const pendingPromise = ReadableStreamAddReadRequest(stream);752 ReadableStreamDefaultControllerCallPullIfNeeded(this);753 return pendingPromise;754 }755}756// Abstract operations for the ReadableStreamDefaultController.757function IsReadableStreamDefaultController(x) {758 if (!typeIsObject(x)) {759 return false;760 }761 if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {762 return false;763 }764 return true;765}766function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {767 const shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);768 if (shouldPull === false) {769 return undefined;770 }771 if (controller._pulling === true) {772 controller._pullAgain = true;773 return undefined;774 }775 assert(controller._pullAgain === false);776 controller._pulling = true;777 const pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);778 pullPromise.then(779 () => {780 controller._pulling = false;781 if (controller._pullAgain === true) {782 controller._pullAgain = false;783 return ReadableStreamDefaultControllerCallPullIfNeeded(controller);784 }785 return undefined;786 },787 e => {788 ReadableStreamDefaultControllerErrorIfNeeded(controller, e);789 }790 )791 .catch(rethrowAssertionErrorRejection);792 return undefined;793}794function ReadableStreamDefaultControllerShouldCallPull(controller) {795 const stream = controller._controlledReadableStream;796 if (stream._state === 'closed' || stream._state === 'errored') {797 return false;798 }799 if (controller._closeRequested === true) {800 return false;801 }802 if (controller._started === false) {803 return false;804 }805 if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {806 return true;807 }808 const desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);809 if (desiredSize > 0) {810 return true;811 }812 return false;813}814// A client of ReadableStreamDefaultController may use these functions directly to bypass state check.815function ReadableStreamDefaultControllerClose(controller) {816 const stream = controller._controlledReadableStream;817 assert(controller._closeRequested === false);818 assert(stream._state === 'readable');819 controller._closeRequested = true;820 if (controller._queue.length === 0) {821 ReadableStreamClose(stream);822 }823}824function ReadableStreamDefaultControllerEnqueue(controller, chunk) {825 const stream = controller._controlledReadableStream;826 assert(controller._closeRequested === false);827 assert(stream._state === 'readable');828 if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {829 ReadableStreamFulfillReadRequest(stream, chunk, false);830 } else {831 let chunkSize = 1;832 if (controller._strategySize !== undefined) {833 const strategySize = controller._strategySize;834 try {835 chunkSize = strategySize(chunk);836 } catch (chunkSizeE) {837 ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);838 throw chunkSizeE;839 }840 }841 try {842 EnqueueValueWithSize(controller._queue, chunk, chunkSize);843 } catch (enqueueE) {844 ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);845 throw enqueueE;846 }847 }848 ReadableStreamDefaultControllerCallPullIfNeeded(controller);849 return undefined;850}851function ReadableStreamDefaultControllerError(controller, e) {852 const stream = controller._controlledReadableStream;853 assert(stream._state === 'readable');854 controller._queue = [];855 ReadableStreamError(stream, e);856}857function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {858 if (controller._controlledReadableStream._state === 'readable') {859 ReadableStreamDefaultControllerError(controller, e);860 }861}862function ReadableStreamDefaultControllerGetDesiredSize(controller) {863 const queueSize = GetTotalQueueSize(controller._queue);864 return controller._strategyHWM - queueSize;865}866class ReadableStreamBYOBRequest {867 constructor(controller, view) {868 this._associatedReadableByteStreamController = controller;869 this._view = view;870 }871 get view() {872 return this._view;873 }874 respond(bytesWritten) {875 if (IsReadableStreamBYOBRequest(this) === false) {876 throw byobRequestBrandCheckException('respond');877 }878 if (this._associatedReadableByteStreamController === undefined) {879 throw new TypeError('This BYOB request has been invalidated');880 }881 ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);882 }883 respondWithNewView(view) {884 if (IsReadableStreamBYOBRequest(this) === false) {885 throw byobRequestBrandCheckException('respond');886 }887 if (this._associatedReadableByteStreamController === undefined) {888 throw new TypeError('This BYOB request has been invalidated');889 }890 if (!ArrayBuffer.isView(view)) {891 throw new TypeError('You can only respond with array buffer views');892 }893 ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);894 }895}896class ReadableByteStreamController {897 constructor(stream, underlyingByteSource, highWaterMark) {898 if (IsReadableStream(stream) === false) {899 throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' +900 'a byte source');901 }902 if (stream._readableStreamController !== undefined) {903 throw new TypeError(904 'ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' +905 'source');906 }907 this._controlledReadableStream = stream;908 this._underlyingByteSource = underlyingByteSource;909 this._pullAgain = false;910 this._pulling = false;911 ReadableByteStreamControllerClearPendingPullIntos(this);912 this._queue = [];913 this._totalQueuedBytes = 0;914 this._closeRequested = false;915 this._started = false;916 this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);917 const autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;918 if (autoAllocateChunkSize !== undefined) {919 if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {920 throw new RangeError('autoAllocateChunkSize must be a positive integer');921 }922 }923 this._autoAllocateChunkSize = autoAllocateChunkSize;924 this._pendingPullIntos = [];925 const controller = this;926 const startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);927 Promise.resolve(startResult).then(928 () => {929 controller._started = true;930 assert(controller._pulling === false);931 assert(controller._pullAgain === false);932 ReadableByteStreamControllerCallPullIfNeeded(controller);933 },934 r => {935 if (stream._state === 'readable') {936 ReadableByteStreamControllerError(controller, r);937 }938 }939 )940 .catch(rethrowAssertionErrorRejection);941 }942 get byobRequest() {943 if (IsReadableByteStreamController(this) === false) {944 throw byteStreamControllerBrandCheckException('byobRequest');945 }946 if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {947 const firstDescriptor = this._pendingPullIntos[0];948 const view = new Uint8Array(firstDescriptor.buffer,949 firstDescriptor.byteOffset + firstDescriptor.bytesFilled,950 firstDescriptor.byteLength - firstDescriptor.bytesFilled);951 this._byobRequest = new ReadableStreamBYOBRequest(this, view);952 }953 return this._byobRequest;954 }955 get desiredSize() {956 if (IsReadableByteStreamController(this) === false) {957 throw byteStreamControllerBrandCheckException('desiredSize');958 }959 return ReadableByteStreamControllerGetDesiredSize(this);960 }961 close() {962 if (IsReadableByteStreamController(this) === false) {963 throw byteStreamControllerBrandCheckException('close');964 }965 if (this._closeRequested === true) {966 throw new TypeError('The stream has already been closed; do not close it again!');967 }968 const state = this._controlledReadableStream._state;969 if (state !== 'readable') {970 throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be closed`);971 }972 ReadableByteStreamControllerClose(this);973 }974 enqueue(chunk) {975 if (IsReadableByteStreamController(this) === false) {976 throw byteStreamControllerBrandCheckException('enqueue');977 }978 if (this._closeRequested === true) {979 throw new TypeError('stream is closed or draining');980 }981 const state = this._controlledReadableStream._state;982 if (state !== 'readable') {983 throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be enqueued to`);984 }985 if (!ArrayBuffer.isView(chunk)) {986 throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');987 }988 ReadableByteStreamControllerEnqueue(this, chunk);989 }990 error(e) {991 if (IsReadableByteStreamController(this) === false) {992 throw byteStreamControllerBrandCheckException('error');993 }994 const stream = this._controlledReadableStream;995 if (stream._state !== 'readable') {996 throw new TypeError(`The stream is ${stream._state} and so cannot be errored`);997 }998 ReadableByteStreamControllerError(this, e);999 }1000 [InternalCancel](reason) {1001 if (this._pendingPullIntos.length > 0) {1002 const firstDescriptor = this._pendingPullIntos[0];1003 firstDescriptor.bytesFilled = 0;1004 }1005 this._queue = [];1006 this._totalQueuedBytes = 0;1007 return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);1008 }1009 [InternalPull]() {1010 const stream = this._controlledReadableStream;1011 assert(ReadableStreamHasDefaultReader(stream) === true);1012 if (this._totalQueuedBytes > 0) {1013 assert(ReadableStreamGetNumReadRequests(stream) === 0);1014 const entry = this._queue.shift();1015 this._totalQueuedBytes -= entry.byteLength;1016 ReadableByteStreamControllerHandleQueueDrain(this);1017 let view;1018 try {1019 view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);1020 } catch (viewE) {1021 return Promise.reject(viewE);1022 }1023 return Promise.resolve(CreateIterResultObject(view, false));1024 }1025 const autoAllocateChunkSize = this._autoAllocateChunkSize;1026 if (autoAllocateChunkSize !== undefined) {1027 let buffer;1028 try {1029 buffer = new ArrayBuffer(autoAllocateChunkSize);1030 } catch (bufferE) {1031 return Promise.reject(bufferE);1032 }1033 const pullIntoDescriptor = {1034 buffer,1035 byteOffset: 0,1036 byteLength: autoAllocateChunkSize,1037 bytesFilled: 0,1038 elementSize: 1,1039 ctor: Uint8Array,1040 readerType: 'default'1041 };1042 this._pendingPullIntos.push(pullIntoDescriptor);1043 }1044 const promise = ReadableStreamAddReadRequest(stream);1045 ReadableByteStreamControllerCallPullIfNeeded(this);1046 return promise;1047 }1048}1049// Abstract operations for the ReadableByteStreamController.1050function IsReadableByteStreamController(x) {1051 if (!typeIsObject(x)) {1052 return false;1053 }1054 if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {1055 return false;1056 }1057 return true;1058}1059function IsReadableStreamBYOBRequest(x) {1060 if (!typeIsObject(x)) {1061 return false;1062 }1063 if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {1064 return false;1065 }1066 return true;1067}1068function ReadableByteStreamControllerCallPullIfNeeded(controller) {1069 const shouldPull = ReadableByteStreamControllerShouldCallPull(controller);1070 if (shouldPull === false) {1071 return undefined;1072 }1073 if (controller._pulling === true) {1074 controller._pullAgain = true;1075 return undefined;1076 }1077 assert(controller._pullAgain === false);1078 controller._pulling = true;1079 // TODO: Test controller argument1080 const pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);1081 pullPromise.then(1082 () => {1083 controller._pulling = false;1084 if (controller._pullAgain === true) {1085 controller._pullAgain = false;1086 ReadableByteStreamControllerCallPullIfNeeded(controller);1087 }1088 },1089 e => {1090 if (controller._controlledReadableStream._state === 'readable') {1091 ReadableByteStreamControllerError(controller, e);1092 }1093 }1094 )1095 .catch(rethrowAssertionErrorRejection);1096 return undefined;1097}1098function ReadableByteStreamControllerClearPendingPullIntos(controller) {1099 ReadableByteStreamControllerInvalidateBYOBRequest(controller);1100 controller._pendingPullIntos = [];1101}1102function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {1103 assert(stream._state !== 'errored', 'state must not be errored');1104 let done = false;1105 if (stream._state === 'closed') {1106 assert(pullIntoDescriptor.bytesFilled === 0);1107 done = true;1108 }1109 const filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);1110 if (pullIntoDescriptor.readerType === 'default') {1111 ReadableStreamFulfillReadRequest(stream, filledView, done);1112 } else {1113 assert(pullIntoDescriptor.readerType === 'byob');1114 ReadableStreamFulfillReadIntoRequest(stream, filledView, done);1115 }1116}1117function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {1118 const bytesFilled = pullIntoDescriptor.bytesFilled;1119 const elementSize = pullIntoDescriptor.elementSize;1120 assert(bytesFilled <= pullIntoDescriptor.byteLength);1121 assert(bytesFilled % elementSize === 0);1122 return new pullIntoDescriptor.ctor(1123 pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);1124}1125function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {1126 controller._queue.push({ buffer, byteOffset, byteLength });1127 controller._totalQueuedBytes += byteLength;1128}1129function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {1130 const elementSize = pullIntoDescriptor.elementSize;1131 const currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;1132 const maxBytesToCopy = Math.min(controller._totalQueuedBytes,1133 pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);1134 const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;1135 const maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;1136 let totalBytesToCopyRemaining = maxBytesToCopy;1137 let ready = false;1138 if (maxAlignedBytes > currentAlignedBytes) {1139 totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;1140 ready = true;1141 }1142 const queue = controller._queue;1143 while (totalBytesToCopyRemaining > 0) {1144 const headOfQueue = queue[0];1145 const bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);1146 const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;1147 ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);1148 if (headOfQueue.byteLength === bytesToCopy) {1149 queue.shift();1150 } else {1151 headOfQueue.byteOffset += bytesToCopy;1152 headOfQueue.byteLength -= bytesToCopy;1153 }1154 controller._totalQueuedBytes -= bytesToCopy;1155 ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);1156 totalBytesToCopyRemaining -= bytesToCopy;1157 }1158 if (ready === false) {1159 assert(controller._totalQueuedBytes === 0, 'queue must be empty');1160 assert(pullIntoDescriptor.bytesFilled > 0);1161 assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);1162 }1163 return ready;1164}1165function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {1166 assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);1167 ReadableByteStreamControllerInvalidateBYOBRequest(controller);1168 pullIntoDescriptor.bytesFilled += size;1169}1170function ReadableByteStreamControllerHandleQueueDrain(controller) {1171 assert(controller._controlledReadableStream._state === 'readable');1172 if (controller._totalQueuedBytes === 0 && controller._closeRequested === true) {1173 ReadableStreamClose(controller._controlledReadableStream);1174 } else {1175 ReadableByteStreamControllerCallPullIfNeeded(controller);1176 }1177}1178function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {1179 if (controller._byobRequest === undefined) {1180 return;1181 }1182 controller._byobRequest._associatedReadableByteStreamController = undefined;1183 controller._byobRequest._view = undefined;1184 controller._byobRequest = undefined;1185}1186function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {1187 assert(controller._closeRequested === false);1188 while (controller._pendingPullIntos.length > 0) {1189 if (controller._totalQueuedBytes === 0) {1190 return;1191 }1192 const pullIntoDescriptor = controller._pendingPullIntos[0];1193 if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {1194 ReadableByteStreamControllerShiftPendingPullInto(controller);1195 ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);1196 }1197 }1198}1199function ReadableByteStreamControllerPullInto(controller, view) {1200 const stream = controller._controlledReadableStream;1201 let elementSize = 1;1202 if (view.constructor !== DataView) {1203 elementSize = view.constructor.BYTES_PER_ELEMENT;1204 }1205 const ctor = view.constructor;1206 const pullIntoDescriptor = {1207 buffer: view.buffer,1208 byteOffset: view.byteOffset,1209 byteLength: view.byteLength,1210 bytesFilled: 0,1211 elementSize,1212 ctor,1213 readerType: 'byob'1214 };1215 if (controller._pendingPullIntos.length > 0) {1216 pullIntoDescriptor.buffer = SameRealmTransfer(pullIntoDescriptor.buffer);1217 controller._pendingPullIntos.push(pullIntoDescriptor);1218 // No ReadableByteStreamControllerCallPullIfNeeded() call since:1219 // - No change happens on desiredSize1220 // - The source has already been notified of that there's at least 1 pending read(view)1221 return ReadableStreamAddReadIntoRequest(stream);1222 }1223 if (stream._state === 'closed') {1224 const emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);1225 return Promise.resolve(CreateIterResultObject(emptyView, true));1226 }1227 if (controller._totalQueuedBytes > 0) {1228 if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {1229 const filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);1230 ReadableByteStreamControllerHandleQueueDrain(controller);1231 return Promise.resolve(CreateIterResultObject(filledView, false));1232 }1233 if (controller._closeRequested === true) {1234 const e = new TypeError('Insufficient bytes to fill elements in the given buffer');1235 ReadableByteStreamControllerError(controller, e);1236 return Promise.reject(e);1237 }1238 }1239 pullIntoDescriptor.buffer = SameRealmTransfer(pullIntoDescriptor.buffer);1240 controller._pendingPullIntos.push(pullIntoDescriptor);1241 const promise = ReadableStreamAddReadIntoRequest(stream);1242 ReadableByteStreamControllerCallPullIfNeeded(controller);1243 return promise;1244}1245function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {1246 firstDescriptor.buffer = SameRealmTransfer(firstDescriptor.buffer);1247 assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');1248 const stream = controller._controlledReadableStream;1249 while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {1250 const pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);1251 ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);1252 }1253}1254function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {1255 if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {1256 throw new RangeError('bytesWritten out of range');1257 }1258 ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);1259 if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {1260 // TODO: Figure out whether we should detach the buffer or not here.1261 return;1262 }1263 ReadableByteStreamControllerShiftPendingPullInto(controller);1264 const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;1265 if (remainderSize > 0) {1266 const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;1267 const remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);1268 ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);1269 }1270 pullIntoDescriptor.buffer = SameRealmTransfer(pullIntoDescriptor.buffer);1271 pullIntoDescriptor.bytesFilled -= remainderSize;1272 ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);1273 ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);1274}1275function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {1276 const firstDescriptor = controller._pendingPullIntos[0];1277 const stream = controller._controlledReadableStream;1278 if (stream._state === 'closed') {1279 if (bytesWritten !== 0) {1280 throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');1281 }1282 ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);1283 } else {1284 assert(stream._state === 'readable');1285 ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);1286 }1287}1288function ReadableByteStreamControllerShiftPendingPullInto(controller) {1289 const descriptor = controller._pendingPullIntos.shift();1290 ReadableByteStreamControllerInvalidateBYOBRequest(controller);1291 return descriptor;1292}1293function ReadableByteStreamControllerShouldCallPull(controller) {1294 const stream = controller._controlledReadableStream;1295 if (stream._state !== 'readable') {1296 return false;1297 }1298 if (controller._closeRequested === true) {1299 return false;1300 }1301 if (controller._started === false) {1302 return false;1303 }1304 if (ReadableStreamHasDefaultReader(stream) && ReadableStreamGetNumReadRequests(stream) > 0) {1305 return true;1306 }1307 if (ReadableStreamHasBYOBReader(stream) && ReadableStreamGetNumReadIntoRequests(stream) > 0) {1308 return true;1309 }1310 if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {1311 return true;1312 }1313 return false;1314}1315// A client of ReadableByteStreamController may use these functions directly to bypass state check.1316function ReadableByteStreamControllerClose(controller) {1317 const stream = controller._controlledReadableStream;1318 assert(controller._closeRequested === false);1319 assert(stream._state === 'readable');1320 if (controller._totalQueuedBytes > 0) {1321 controller._closeRequested = true;1322 return;1323 }1324 if (controller._pendingPullIntos.length > 0) {1325 const firstPendingPullInto = controller._pendingPullIntos[0];1326 if (firstPendingPullInto.bytesFilled > 0) {1327 const e = new TypeError('Insufficient bytes to fill elements in the given buffer');1328 ReadableByteStreamControllerError(controller, e);1329 throw e;1330 }1331 }1332 ReadableStreamClose(stream);1333}1334function ReadableByteStreamControllerEnqueue(controller, chunk) {1335 const stream = controller._controlledReadableStream;1336 assert(controller._closeRequested === false);1337 assert(stream._state === 'readable');1338 const buffer = chunk.buffer;1339 const byteOffset = chunk.byteOffset;1340 const byteLength = chunk.byteLength;1341 const transferredBuffer = SameRealmTransfer(buffer);1342 if (ReadableStreamHasDefaultReader(stream) === true) {1343 if (ReadableStreamGetNumReadRequests(stream) === 0) {1344 ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);1345 } else {1346 assert(controller._queue.length === 0);1347 const transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);1348 ReadableStreamFulfillReadRequest(stream, transferredView, false);1349 }1350 } else if (ReadableStreamHasBYOBReader(stream) === true) {1351 // TODO: Ideally in this branch detaching should happen only if the buffer is not consumed fully.1352 ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);1353 ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);1354 } else {1355 assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');1356 ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);1357 }1358}1359function ReadableByteStreamControllerError(controller, e) {1360 const stream = controller._controlledReadableStream;1361 assert(stream._state === 'readable');1362 ReadableByteStreamControllerClearPendingPullIntos(controller);1363 controller._queue = [];1364 ReadableStreamError(stream, e);1365}1366function ReadableByteStreamControllerGetDesiredSize(controller) {1367 return controller._strategyHWM - controller._totalQueuedBytes;1368}1369function ReadableByteStreamControllerRespond(controller, bytesWritten) {1370 bytesWritten = Number(bytesWritten);1371 if (IsFiniteNonNegativeNumber(bytesWritten) === false) {1372 throw new RangeError('bytesWritten must be a finite');1373 }1374 assert(controller._pendingPullIntos.length > 0);1375 ReadableByteStreamControllerRespondInternal(controller, bytesWritten);1376}1377function ReadableByteStreamControllerRespondWithNewView(controller, view) {1378 assert(controller._pendingPullIntos.length > 0);1379 const firstDescriptor = controller._pendingPullIntos[0];1380 if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {1381 throw new RangeError('The region specified by view does not match byobRequest');1382 }1383 if (firstDescriptor.byteLength !== view.byteLength) {1384 throw new RangeError('The buffer of view has different capacity than byobRequest');1385 }1386 firstDescriptor.buffer = view.buffer;1387 ReadableByteStreamControllerRespondInternal(controller, view.byteLength);1388}1389// Helper functions for the ReadableStream.1390function streamBrandCheckException(name) {1391 return new TypeError(`ReadableStream.prototype.${name} can only be used on a ReadableStream`);1392}1393// Helper functions for the readers.1394function readerLockException(name) {1395 return new TypeError('Cannot ' + name + ' a stream using a released reader');1396}1397// Helper functions for the ReadableStreamDefaultReader.1398function defaultReaderBrandCheckException(name) {1399 return new TypeError(1400 `ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`);1401}1402function defaultReaderClosedPromiseInitialize(reader) {1403 reader._closedPromise = new Promise((resolve, reject) => {1404 reader._closedPromise_resolve = resolve;1405 reader._closedPromise_reject = reject;1406 });1407}1408function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {1409 reader._closedPromise = Promise.reject(reason);1410 reader._closedPromise_resolve = undefined;1411 reader._closedPromise_reject = undefined;1412}...
default-reader.ts
Source:default-reader.ts
...94 * or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.95 */96 get closed(): Promise<void> {97 if (!IsReadableStreamDefaultReader(this)) {98 return promiseRejectedWith(defaultReaderBrandCheckException('closed'));99 }100 return this._closedPromise;101 }102 /**103 * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.104 */105 cancel(reason: any = undefined): Promise<void> {106 if (!IsReadableStreamDefaultReader(this)) {107 return promiseRejectedWith(defaultReaderBrandCheckException('cancel'));108 }109 if (this._ownerReadableStream === undefined) {110 return promiseRejectedWith(readerLockException('cancel'));111 }112 return ReadableStreamReaderGenericCancel(this, reason);113 }114 /**115 * Returns a promise that allows access to the next chunk from the stream's internal queue, if available.116 *117 * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.118 */119 read(): Promise<ReadableStreamDefaultReadResult<R>> {120 if (!IsReadableStreamDefaultReader(this)) {121 return promiseRejectedWith(defaultReaderBrandCheckException('read'));122 }123 if (this._ownerReadableStream === undefined) {124 return promiseRejectedWith(readerLockException('read from'));125 }126 let resolvePromise!: (result: ReadableStreamDefaultReadResult<R>) => void;127 let rejectPromise!: (reason: any) => void;128 const promise = newPromise<ReadableStreamDefaultReadResult<R>>((resolve, reject) => {129 resolvePromise = resolve;130 rejectPromise = reject;131 });132 const readRequest: ReadRequest<R> = {133 _chunkSteps: chunk => resolvePromise({ value: chunk, done: false }),134 _closeSteps: () => resolvePromise({ value: undefined, done: true }),135 _errorSteps: e => rejectPromise(e)136 };137 ReadableStreamDefaultReaderRead(this, readRequest);138 return promise;139 }140 /**141 * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.142 * If the associated stream is errored when the lock is released, the reader will appear errored in the same way143 * from now on; otherwise, the reader will appear closed.144 *145 * A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by146 * the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to147 * do so will throw a `TypeError` and leave the reader locked to the stream.148 */149 releaseLock(): void {150 if (!IsReadableStreamDefaultReader(this)) {151 throw defaultReaderBrandCheckException('releaseLock');152 }153 if (this._ownerReadableStream === undefined) {154 return;155 }156 if (this._readRequests.length > 0) {157 throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');158 }159 ReadableStreamReaderGenericRelease(this);160 }161}162Object.defineProperties(ReadableStreamDefaultReader.prototype, {163 cancel: { enumerable: true },164 read: { enumerable: true },165 releaseLock: { enumerable: true },166 closed: { enumerable: true }167});168if (typeof Symbol.toStringTag === 'symbol') {169 Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {170 value: 'ReadableStreamDefaultReader',171 configurable: true172 });173}174// Abstract operations for the readers.175export function IsReadableStreamDefaultReader<R = any>(x: any): x is ReadableStreamDefaultReader<R> {176 if (!typeIsObject(x)) {177 return false;178 }179 if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {180 return false;181 }182 return true;183}184export function ReadableStreamDefaultReaderRead<R>(reader: ReadableStreamDefaultReader<R>,185 readRequest: ReadRequest<R>): void {186 const stream = reader._ownerReadableStream;187 assert(stream !== undefined);188 stream._disturbed = true;189 if (stream._state === 'closed') {190 readRequest._closeSteps();191 } else if (stream._state === 'errored') {192 readRequest._errorSteps(stream._storedError);193 } else {194 assert(stream._state === 'readable');195 stream._readableStreamController[PullSteps](readRequest as ReadRequest<any>);196 }197}198// Helper functions for the ReadableStreamDefaultReader.199function defaultReaderBrandCheckException(name: string): TypeError {200 return new TypeError(201 `ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`);...
Using AI Code Generation
1var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');2var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();3wptbReaderBrandCheckExceptionObj.defaultReaderBrandCheckException(function(error, data){4if(error){5console.log(error);6}7else{8console.log(data);9}10});11{12"data": {13}14}15var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');16var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();17var data = {18};19wptbReaderBrandCheckExceptionObj.createReaderBrandCheckException(data, function(error, data){20if(error){21console.log(error);22}23else{24console.log(data);25}26});27{28"data": {29}30}31var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');32var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();33var data = {34};35wptbReaderBrandCheckExceptionObj.getReaderBrandCheckException(data, function(error, data){36if(error){37console.log(error);38}39else{40console.log(data);41}42});43{44"data": {45"readerBrandCheckException": {46}47}48}49var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');50var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();51var data = {52};
Using AI Code Generation
1var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');2var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();3wptbReaderBrandCheckExceptionObj.defaultReaderBrandCheckException('test');4var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');5var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();6wptbReaderBrandCheckExceptionObj.setReaderBrandCheckException('test');7var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');8var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();9wptbReaderBrandCheckExceptionObj.getReaderBrandCheckException('test');10var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');11var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();12wptbReaderBrandCheckExceptionObj.defaultReaderBrandCheckException('test');13var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');14var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();15wptbReaderBrandCheckExceptionObj.setReaderBrandCheckException('test');16var wptbReaderBrandCheckException = require('wptbReaderBrandCheckException');17var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();18wptbReaderBrandCheckExceptionObj.getReaderBrandCheckException('test');
Using AI Code Generation
1var wptReaderBrandCheckException = require('wptReaderBrandCheckException');2wptReaderBrandCheckException.defaultReaderBrandCheckException();3var wptReaderBrandCheckException = require('wptReaderBrandCheckException');4wptReaderBrandCheckException.defaultReaderBrandCheckException();5var wptReaderBrandCheckException = require('wptReaderBrandCheckException');6wptReaderBrandCheckException.defaultReaderBrandCheckException();7var wptReaderBrandCheckException = require('wptReaderBrandCheckException');8wptReaderBrandCheckException.defaultReaderBrandCheckException();9var wptReaderBrandCheckException = require('wptReaderBrandCheckException');10wptReaderBrandCheckException.defaultReaderBrandCheckException();11var wptReaderBrandCheckException = require('wptReaderBrandCheckException');12wptReaderBrandCheckException.defaultReaderBrandCheckException();13var wptReaderBrandCheckException = require('wptReaderBrandCheckException');14wptReaderBrandCheckException.defaultReaderBrandCheckException();15var wptReaderBrandCheckException = require('wptReaderBrandCheckException');16wptReaderBrandCheckException.defaultReaderBrandCheckException();17var wptReaderBrandCheckException = require('wptReaderBrandCheckException');18wptReaderBrandCheckException.defaultReaderBrandCheckException();
Using AI Code Generation
1var wptbReaderBrandCheckExceptionObj = new wptbReaderBrandCheckException();2wptbReaderBrandCheckExceptionObj.defaultReaderBrandCheckException();3function wptbReaderBrandCheckException() {4 this.defaultReaderBrandCheckException = function () {5 try {6 var readerBrandCheckException = new ActiveXObject("Wptb.Reader.BrandCheckException");7 readerBrandCheckException.message = "Reader Brand Check Exception";8 readerBrandCheckException.number = 123;9 throw readerBrandCheckException;10 }11 catch (e) {12 var error = new Error();13 error.message = e.message;14 error.number = e.number;15 throw error;16 }17 }18}19var wptbReaderCardExceptionObj = new wptbReaderCardException();20wptbReaderCardExceptionObj.defaultReaderCardException();21function wptbReaderCardException() {22 this.defaultReaderCardException = function () {23 try {24 var readerCardException = new ActiveXObject("Wptb.Reader.CardException");25 readerCardException.message = "Reader Card Exception";26 readerCardException.number = 123;27 throw readerCardException;28 }29 catch (e) {30 var error = new Error();31 error.message = e.message;32 error.number = e.number;33 throw error;34 }35 }36}37var wptbReaderCardNotPresentExceptionObj = new wptbReaderCardNotPresentException();38wptbReaderCardNotPresentExceptionObj.defaultReaderCardNotPresentException();39function wptbReaderCardNotPresentException() {40 this.defaultReaderCardNotPresentException = function () {41 try {42 var readerCardNotPresentException = new ActiveXObject("Wptb.Reader.CardNotPresentException");43 readerCardNotPresentException.message = "Reader Card Not Present Exception";44 readerCardNotPresentException.number = 123;45 throw readerCardNotPresentException;46 }47 catch (e) {48 var error = new Error();
Using AI Code Generation
1function defaultReaderBrandCheckException() {2 var exception = wptCommon.defaultReaderBrandCheckException();3 if (exception) {4 return exception;5 }6 return "No exception";7}8function defaultReaderBrandCheckException() {9 var exception = wptCommon.defaultReaderBrandCheckException();10 if (exception) {11 return exception;12 }13 return "No exception";14}15function defaultReaderBrandCheckException() {16 var exception = wptCommon.defaultReaderBrandCheckException();17 if (exception) {18 return exception;19 }20 return "No exception";21}22function defaultReaderBrandCheckException() {23 var exception = wptCommon.defaultReaderBrandCheckException();24 if (exception) {25 return exception;26 }27 return "No exception";28}29function defaultReaderBrandCheckException() {30 var exception = wptCommon.defaultReaderBrandCheckException();31 if (exception) {32 return exception;33 }34 return "No exception";35}36function defaultReaderBrandCheckException() {37 var exception = wptCommon.defaultReaderBrandCheckException();38 if (exception) {39 return exception;40 }41 return "No exception";42}43function defaultReaderBrandCheckException() {44 var exception = wptCommon.defaultReaderBrandCheckException();45 if (exception) {46 return exception;47 }48 return "No exception";49}50function defaultReaderBrandCheckException() {51 var exception = wptCommon.defaultReaderBrandCheckException();52 if (exception) {53 return exception;54 }55 return "No exception";56}
Using AI Code Generation
1var wptoolkit = require('wptoolkit.js');2var wp = new wptoolkit();3wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");4var wptoolkit = require('wptoolkit.js');5var wp = new wptoolkit();6wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");7var wptoolkit = require('wptoolkit.js');8var wp = new wptoolkit();9wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");10var wptoolkit = require('wptoolkit.js');11var wp = new wptoolkit();12wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");13var wptoolkit = require('wptoolkit.js');14var wp = new wptoolkit();15wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");16var wptoolkit = require('wptoolkit.js');17var wp = new wptoolkit();18wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");19var wptoolkit = require('wptoolkit.js');20var wp = new wptoolkit();21wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");22var wptoolkit = require('wptoolkit.js');23var wp = new wptoolkit();24wp.defaultReaderBrandCheckException("NFC", "NXP", "NFC");
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!