(data)
| 66 | |
| 67 | // ==================== 压缩/解压 ==================== |
| 68 | function compress(data) { |
| 69 | const compressed = deflateRawSync(data); |
| 70 | const result = Buffer.alloc(4 + compressed.length); |
| 71 | result.writeUInt32LE(data.length, 0); |
| 72 | compressed.copy(result, 4); |
| 73 | return result; |
| 74 | } |
| 75 | |
| 76 | function decompress(data) { |
| 77 | if (data.length < 4) throw new Error('Data too short'); |