compression icon indicating copy to clipboard operation
compression copied to clipboard

User-supplied algorithms and algorithm enumeration

Open ricea opened this issue 6 years ago • 2 comments
trafficstars

There should be a way to register algorithms that are not built-in but can be used to construct CompressionStream and DecompressionStreams in the same realm.

@domenic provided the following API sketch:

dictionary TransformStreamInit {
  required ReadableStream readable;
  required WritableStream writable;
};

callback CompressionAlgorithm = Promise<TransformStreamInit> (DOMString format, object options);

interface CompressionAlgorithms {
  maplike<DOMString, CompressionAlgorithm>;
};

partial interface CompressionStream {
  static CompressionAlgorithms algorithms;
};
CompressionStream.algorithms.set(
  "foo",
  () => ({ readable: ..., writable: ... })
);

CompressionStream.algorithms.has('foo');
CompressionStream.algorithms.keys();

Internally, the set of available algorithms would be stored in an internal slot on the global object.

ricea avatar Oct 15 '19 08:10 ricea

is this so that you can detect if eg deflate, gzip, deflate-raw, brotli is supported and if not you can add (polyfill) them yourself?

...if so maybe #6 can be closed in favor of this one?

jimmywarting avatar Nov 03 '20 18:11 jimmywarting

is this so that you can detect if eg deflate, gzip, deflate-raw, brotli is supported and if not you can add (polyfill) them yourself?

Yes.

...if so maybe #6 can be closed in favor of this one?

#6 is for detecting which format a particular object was constructed with. So it's still (mildly) useful.

ricea avatar Nov 04 '20 20:11 ricea