⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
invoice
/
node_modules
/
gzip-size
/
View File Name :
index.js
'use strict'; const fs = require('fs'); const stream = require('stream'); const zlib = require('zlib'); const duplexer = require('duplexer'); const pify = require('pify'); const getOptions = options => Object.assign({level: 9}, options); module.exports = (input, options) => { if (!input) { return Promise.resolve(0); } return pify(zlib.gzip)(input, getOptions(options)).then(data => data.length).catch(_ => 0); }; module.exports.sync = (input, options) => zlib.gzipSync(input, getOptions(options)).length; module.exports.stream = options => { const input = new stream.PassThrough(); const output = new stream.PassThrough(); const wrapper = duplexer(input, output); let gzipSize = 0; const gzip = zlib.createGzip(getOptions(options)) .on('data', buf => { gzipSize += buf.length; }) .on('error', () => { wrapper.gzipSize = 0; }) .on('end', () => { wrapper.gzipSize = gzipSize; wrapper.emit('gzip-size', gzipSize); output.end(); }); input.pipe(gzip); input.pipe(output, {end: false}); return wrapper; }; module.exports.file = (path, options) => { return new Promise((resolve, reject) => { const stream = fs.createReadStream(path); stream.on('error', reject); const gzipStream = stream.pipe(module.exports.stream(options)); gzipStream.on('error', reject); gzipStream.on('gzip-size', resolve); }); }; module.exports.fileSync = (path, options) => module.exports.sync(fs.readFileSync(path), options);