1'use strict'; 2// Test compressing and uncompressing a string with brotli 3 4const common = require('../common'); 5const assert = require('assert'); 6const zlib = require('zlib'); 7 8const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' + 9 't. Morbi faucibus, purus at gravida dictum, libero arcu ' + 10 'convallis lacus, in commodo libero metus eu nisi. Nullam' + 11 ' commodo, neque nec porta placerat, nisi est fermentum a' + 12 'ugue, vitae gravida tellus sapien sit amet tellus. Aenea' + 13 'n non diam orci. Proin quis elit turpis. Suspendisse non' + 14 ' diam ipsum. Suspendisse nec ullamcorper odio. Vestibulu' + 15 'm arcu mi, sodales non suscipit id, ultrices ut massa. S' + 16 'ed ac sem sit amet arcu malesuada fermentum. Nunc sed. '; 17const compressedString = 'G/gBQBwHdky2aHV5KK9Snf05//1pPdmNw/7232fnIm1IB' + 18 'K1AA8RsN8OB8Nb7Lpgk3UWWUlzQXZyHQeBBbXMTQXC1j7' + 19 'wg3LJs9LqOGHRH2bj/a2iCTLLx8hBOyTqgoVuD1e+Qqdn' + 20 'f1rkUNyrWq6LtOhWgxP3QUwdhKGdZm3rJWaDDBV7+pDk1' + 21 'MIkrmjp4ma2xVi5MsgJScA3tP1I7mXeby6MELozrwoBQD' + 22 'mVTnEAicZNj4lkGqntJe2qSnGyeMmcFgraK94vCg/4iLu' + 23 'Tw5RhKhnVY++dZ6niUBmRqIutsjf5TzwF5iAg8a9UkjF5' + 24 '2eZ0tB2vo6v8SqVfNMkBmmhxr0NT9LkYF69aEjlYzj7IE' + 25 'KmEUQf1HBogRYhFIt4ymRNEgHAIzOyNEsQM='; 26 27zlib.brotliCompress(inputString, common.mustCall((err, buffer) => { 28 assert(inputString.length > buffer.length); 29 30 zlib.brotliDecompress(buffer, common.mustCall((err, buffer) => { 31 assert.strictEqual(buffer.toString(), inputString); 32 })); 33})); 34 35const buffer = Buffer.from(compressedString, 'base64'); 36zlib.brotliDecompress(buffer, common.mustCall((err, buffer) => { 37 assert.strictEqual(buffer.toString(), inputString); 38})); 39