GithubHelp home page GithubHelp logo

offroaders123 / compression-streams-polyfill Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 101arrowz/compression-streams-polyfill

0.0 1.0 0.0 79 KB

Polyfill for the Compression Streams API

TypeScript 100.00%

compression-streams-polyfill's Introduction

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 [email protected]
-->
<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

compression-streams-polyfill's People

Contributors

101arrowz avatar offroaders123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.