feat: add backpressure support
This commit is contained in:
@@ -28,7 +28,7 @@ async function collectTags(decoder: Decoder): Promise<EbmlTagType[]> {
|
||||
return tags;
|
||||
}
|
||||
|
||||
describe('EbmlStreamDecoder', () => {
|
||||
describe('Ebml Decoder', () => {
|
||||
it('should wait for more data if a tag is longer than the buffer', async () => {
|
||||
const decoder = getDecoderWithNullSink();
|
||||
const writer = decoder.writable.getWriter();
|
||||
|
||||
@@ -56,7 +56,9 @@ const makeEncoderTest = async (tags: EbmlTagTrait[]) => {
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
|
||||
const encoder = new EbmlStreamEncoder();
|
||||
|
||||
const chunks: ArrayBuffer[] = [];
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
@@ -70,6 +72,9 @@ const makeEncoderTest = async (tags: EbmlTagTrait[]) => {
|
||||
close() {
|
||||
resolve();
|
||||
},
|
||||
abort: (e) => {
|
||||
reject(e);
|
||||
},
|
||||
})
|
||||
)
|
||||
.catch(reject);
|
||||
@@ -106,16 +111,15 @@ describe('EBML Encoder', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
describe('#writeTag', () => {
|
||||
it('throws with an incomplete tag data', async () => {
|
||||
await expect(() => makeEncoderTest([incompleteTag])).rejects.toThrow(
|
||||
/should only accept embl tag but not/
|
||||
);
|
||||
});
|
||||
it('throws with an invalid tag id', async () => {
|
||||
await expect(() => makeEncoderTest([invalidTag])).rejects.toThrow(
|
||||
/should only accept embl tag but not/
|
||||
);
|
||||
});
|
||||
it('throws with an incomplete tag data', async () => {
|
||||
await expect(() => makeEncoderTest([incompleteTag])).rejects.toThrow(
|
||||
/should only accept embl tag but not/
|
||||
);
|
||||
});
|
||||
|
||||
it('throws with an invalid tag id', async () => {
|
||||
await expect(() => makeEncoderTest([invalidTag])).rejects.toThrow(
|
||||
/should only accept embl tag but not/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user