當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ReadableStreamReader.read函數代碼示例

本文整理匯總了TypeScript中src/streams/ReadableStreamReader.read函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript read函數的具體用法?TypeScript read怎麽用?TypeScript read使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了read函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

		return reader.read().then(function (result: ReadResult<Event>) {
			assert.strictEqual(result.value, appleEvent);

			return reader.read().then(function (result: ReadResult<Event>) {
				assert.strictEqual(result.value, orangeEvent);
			});
		});
開發者ID:Gamelena,項目名稱:core,代碼行數:7,代碼來源:EventedStreamSource.ts

示例2: readNext

		function readNext(): Promise<void> {
			return reader.read().then(function (result: ReadResult<number>) {
				if (result.done) {
					return Promise.resolve();
				}
				else {
					results.push(result.value);
					return readNext();
				}
			});
		}
開發者ID:jdonaghue,項目名稱:core,代碼行數:11,代碼來源:TransformStream.ts

示例3:

		return stream.writable.write(testValue).then(function () {
			return reader.read().then(function (result: ReadResult<number>) {
				assert.strictEqual(result.value, testValue.charCodeAt(0));
			});
		});
開發者ID:jdonaghue,項目名稱:core,代碼行數:5,代碼來源:TransformStream.ts

示例4: registerSuite

registerSuite({
	name: 'EventedStreamSource',

	beforeEach() {
		emitter = new Evented();
		source = new EventedStreamSource(emitter, 'testEvent');
		stream = new ReadableStream<Event>(source);
		reader = stream.getReader();

		return stream.started;
	},

	start() {
		emitter.emit(testEvent);

		return reader.read().then(function (result: ReadResult<Event>) {
			assert.strictEqual(result.value, testEvent,
				'Event read from stream should be the same as the event emitted by emitter');
		});
	},

	'event array'() {
		let appleEvent = {
			type: 'apple',
			test: 'value'
		};
		let orangeEvent = {
			type: 'orange',
			test: 'value'
		};
開發者ID:Gamelena,項目名稱:core,代碼行數:30,代碼來源:EventedStreamSource.ts


注:本文中的src/streams/ReadableStreamReader.read函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。