diff options
author | Nick Stott <nick@nickstott.com> | 2019-10-28 12:41:36 -0400 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-10-28 12:41:36 -0400 |
commit | 65d9286203cf239f68c6015818e82e8521e600a1 (patch) | |
tree | 0af1a7be449036f2f4ae9d3ecf06b7d645c8bddc /cli/js/streams/strategies.ts | |
parent | 967c236fa5fb1e87e1b5ee788fe77d3a07361da1 (diff) |
Re-enable basic stream support for fetch bodies (#3192)
* Add sd-streams from https://github.com/stardazed/sd-streams/blob/master/packages/streams/src/
* change the interfaces in dom_types to match what sd-streams expects
Diffstat (limited to 'cli/js/streams/strategies.ts')
-rw-r--r-- | cli/js/streams/strategies.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cli/js/streams/strategies.ts b/cli/js/streams/strategies.ts new file mode 100644 index 000000000..5f7ffc632 --- /dev/null +++ b/cli/js/streams/strategies.ts @@ -0,0 +1,39 @@ +// Forked from https://github.com/stardazed/sd-streams/tree/8928cf04b035fd02fb1340b7eb541c76be37e546 +// Copyright (c) 2018-Present by Arthur Langereis - @zenmumbler MIT + +/** + * streams/strategies - implementation of the built-in stream strategies + * Part of Stardazed + * (c) 2018-Present by Arthur Langereis - @zenmumbler + * https://github.com/stardazed/sd-streams + */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ +// TODO reenable this lint here + +import { QueuingStrategy } from "../dom_types.ts"; + +export class ByteLengthQueuingStrategy + implements QueuingStrategy<ArrayBufferView> { + highWaterMark: number; + + constructor(options: { highWaterMark: number }) { + this.highWaterMark = options.highWaterMark; + } + + size(chunk: ArrayBufferView): number { + return chunk.byteLength; + } +} + +export class CountQueuingStrategy implements QueuingStrategy<any> { + highWaterMark: number; + + constructor(options: { highWaterMark: number }) { + this.highWaterMark = options.highWaterMark; + } + + size(): number { + return 1; + } +} |