本文整理匯總了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);
});
});
示例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();
}
});
}
示例3:
return stream.writable.write(testValue).then(function () {
return reader.read().then(function (result: ReadResult<number>) {
assert.strictEqual(result.value, testValue.charCodeAt(0));
});
});
示例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'
};