From 2e590072148c85bbc479ab49aa9556b0a2cfaff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 5 Mar 2020 13:05:41 +0100 Subject: move Web APIs to cli/js/web/ --- cli/js/web/streams/strategies.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cli/js/web/streams/strategies.ts (limited to 'cli/js/web/streams/strategies.ts') diff --git a/cli/js/web/streams/strategies.ts b/cli/js/web/streams/strategies.ts new file mode 100644 index 000000000..5f7ffc632 --- /dev/null +++ b/cli/js/web/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 { + highWaterMark: number; + + constructor(options: { highWaterMark: number }) { + this.highWaterMark = options.highWaterMark; + } + + size(chunk: ArrayBufferView): number { + return chunk.byteLength; + } +} + +export class CountQueuingStrategy implements QueuingStrategy { + highWaterMark: number; + + constructor(options: { highWaterMark: number }) { + this.highWaterMark = options.highWaterMark; + } + + size(): number { + return 1; + } +} -- cgit v1.2.3