compression
compression copied to clipboard
User-supplied algorithms and algorithm enumeration
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.
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?
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.