How to use the compressible function in compressible

To help you get started, we’ve selected a few compressible examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dazejs / daze / packages / framework / src / response / index.ts View on Github external
endWithCompress(request: Request, data: any) {

    // if compress is disable
    const encoding: string | false = request.acceptsEncodings('gzip', 'deflate', 'identity');

    if (!encoding || encoding === 'identity') return this.end(request, data);

    if (!compressible(this.getType())) return this.end(request, data);

    const threshold = this.app.get('config').get('app.threshold', 1024);

    if (threshold > this.getLength()) return this.end(request, data);

    this.setHeader('Content-Encoding', encoding);
    this.removeHeader('Content-Length');

    const stream = encodingMethods[encoding as 'gzip' | 'deflate']({});

    if (data instanceof Stream) {
      data.pipe(stream);
    } else {
      stream.end(data);
    }
github zhuowenli / react-ssr-boilerplate / src / server-instance.js View on Github external
    filter: type => !(/event-stream/i.test(type)) && compressible(type),
}));
github ehmicky / autoserver / src / compress / info.js View on Github external
export const shouldCompress = function({ contentType }) {
  return compressible(contentType)
}

compressible

Compressible Content-Type / mime checking

MIT
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis

Popular compressible functions