You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

compression-streams-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compression-streams-polyfill

Lightweight polyfill/ponyfill for the Compression Streams API

0.1.1
Source
npmnpm
Version published
Weekly downloads
3.1K
-0.19%
Maintainers
1
Weekly downloads
 
Created
Source

compression-streams-polyfill

Lightweight polyfill/ponyfill for the Compression Streams API

Usage

Install:

npm i compression-streams-polyfill # or yarn add, or pnpm add

Import:

import 'compression-streams-polyfill';
// CompressionStream and DecompressionStream are now available

If your environment doesn't support ES Modules:

require('compression-streams-polyfill');

If you want to load from a CDN in the browser:

<!--
You should use either UNPKG or jsDelivr (i.e. only one of the following)
You can specify the version, e.g. with compression-streams-polyfill@0.1.1
-->
<script src="https://unpkg.com/compression-streams-polyfill"></script>
<script src="https://cdn.jsdelivr.net/npm/compression-streams-polyfill"></script>

Ponyfill usage

This polyfill is almost perfectly spec-compliant. Nonetheless, if you'd like to avoid adding CompressionStream and DecompressionStream to the global scope, you can use the ponyfill.

Note that you must supply your own TransformStream implementation to use the ponyfill (though TransformStream is available in most modern browsers).

import { makeCompressionStream, makeDecompressionStream } from 'compression-streams-polyfill/ponyfill';

// If you'd like to also ponyfill TransformStream:
// import { TransformStream } from 'web-streams-polyfill/ponyfill';

const CompressionStream = makeCompressionStream(TransformStream);
const DecompressionStream = makeDecompressionStream(TransformStream);

Performance and size

This polyfill is based on fflate and is therefore very fast. It tends to be between 20% slower and 5% faster than Chromium's native CompressionStream and DecompressionStream.

The polyfill's full bundle size is about 15kB minified, or 6kB gzipped.

License

MIT

Keywords

compression

FAQs

Package last updated on 29 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts