CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
ZlibHeaderTransformStream.js29 linesDownload Raw Back to helpers
1"use strict";2 3import stream from "stream";4 5class ZlibHeaderTransformStream extends stream.Transform {6  __transform(chunk, encoding, callback) {7    this.push(chunk);8    callback();9  }10 11  _transform(chunk, encoding, callback) {12    if (chunk.length !== 0) {13      this._transform = this.__transform;14 15      // Add Default Compression headers if no zlib headers are present16      if (chunk[0] !== 120) { // Hex: 7817        const header = Buffer.alloc(2);18        header[0] = 120; // Hex: 7819        header[1] = 156; // Hex: 9C 20        this.push(header, encoding);21      }22    }23 24    this.__transform(chunk, encoding, callback);25  }26}27 28export default ZlibHeaderTransformStream;29