MCPcopy
hub / github.com/socketio/socket.io / compress

Method compress

packages/engine.io/lib/transports/polling.ts:323–339  ·  view source on GitHub ↗

* Compresses data. * * @private

(data, encoding, callback)

Source from the content-addressed store, hash-verified

321 * @private
322 */
323 private compress(data, encoding, callback) {
324 debug("compressing");
325
326 const buffers = [];
327 let nread = 0;
328
329 compressionMethods[encoding](this.httpCompression)
330 .on("error", callback)
331 .on("data", function (chunk) {
332 buffers.push(chunk);
333 nread += chunk.length;
334 })
335 .on("end", function () {
336 callback(null, Buffer.concat(buffers, nread));
337 })
338 .end(data);
339 }
340
341 /**
342 * Closes the transport.

Callers 1

doWriteMethod · 0.95

Calls 4

debugFunction · 0.85
callbackFunction · 0.50
endMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected