mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2025-11-03 22:21:55 +00:00 
			
		
		
		
	Add helper utility to compress data.
This commit is contained in:
		@@ -21,6 +21,7 @@
 | 
			
		||||
        "linkify-html": "4.1.1",
 | 
			
		||||
        "linkifyjs": "4.1.1",
 | 
			
		||||
        "mux.js": "6.3.0",
 | 
			
		||||
        "pako": "2.1.0",
 | 
			
		||||
        "qrcode": "^1.5.3",
 | 
			
		||||
        "shaka-player": "4.4.1",
 | 
			
		||||
        "stream-browserify": "3.0.0",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							@@ -38,6 +38,9 @@ dependencies:
 | 
			
		||||
  mux.js:
 | 
			
		||||
    specifier: 6.3.0
 | 
			
		||||
    version: 6.3.0
 | 
			
		||||
  pako:
 | 
			
		||||
    specifier: 2.1.0
 | 
			
		||||
    version: 2.1.0
 | 
			
		||||
  qrcode:
 | 
			
		||||
    specifier: ^1.5.3
 | 
			
		||||
    version: 1.5.3
 | 
			
		||||
@@ -4177,6 +4180,10 @@ packages:
 | 
			
		||||
    engines: {node: '>=6'}
 | 
			
		||||
    dev: false
 | 
			
		||||
 | 
			
		||||
  /pako@2.1.0:
 | 
			
		||||
    resolution: {integrity: sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==}
 | 
			
		||||
    dev: false
 | 
			
		||||
 | 
			
		||||
  /parent-module@1.0.1:
 | 
			
		||||
    resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
 | 
			
		||||
    engines: {node: '>=6'}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								src/utils/compressionUtils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/utils/compressionUtils.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
export const compressGzip = async data => {
 | 
			
		||||
    // Firefox does not support CompressionStream yet
 | 
			
		||||
    if (typeof CompressionStream !== "undefined") {
 | 
			
		||||
        let bytes = new TextEncoder().encode(data);
 | 
			
		||||
        // eslint-disable-next-line no-undef
 | 
			
		||||
        const cs = new CompressionStream("gzip");
 | 
			
		||||
        const writer = cs.writable.getWriter();
 | 
			
		||||
        writer.write(bytes);
 | 
			
		||||
        writer.close();
 | 
			
		||||
        const compAb = await new Response(cs.readable).arrayBuffer();
 | 
			
		||||
        bytes = new Uint8Array(compAb);
 | 
			
		||||
 | 
			
		||||
        return bytes;
 | 
			
		||||
    } else {
 | 
			
		||||
        const pako = require("pako");
 | 
			
		||||
        return pako.gzip(data);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user