I'm using Node.JS and I'm trying to convert this string that looks like this
{"blocks":[{"id":"block","block":"event","args":{"items":[]},"action":"Join"},{"id":"block","block":"player_action","args":{"items":[{"item":{"id":"txt","data":{"name":"hi"}},"slot":0},{"item":{"id":"bl_tag","data":{"option":"Add spaces","tag":"Text Value Merging","action":"SendMessage","block":"player_action"}},"slot":25},{"item":{"id":"bl_tag","data":{"option":"Regular","tag":"Alignment Mode","action":"SendMessage","block":"player_action"}},"slot":26}]},"action":"SendMessage"}]}
into Gzip using zlib I have tried following some answers on Stack Overflow like this
var deflated = zlib.deflateSync('{"blocks":[{"id":"block","block":"event","args":{"items":[]},"action":"Join"},{"id":"block","block":"player_action","args":{"items":[{"item":{"id":"txt","data":{"name":"hi"}},"slot":0},{"item":{"id":"bl_tag","data":{"option":"Add spaces","tag":"Text Value Merging","action":"SendMessage","block":"player_action"}},"slot":25},{"item":{"id":"bl_tag","data":{"option":"Regular","tag":"Alignment Mode","action":"SendMessage","block":"player_action"}},"slot":26}]},"action":"SendMessage"}]}').toString('base64');
var inflated = zlib.inflateSync(new Buffer(deflated, 'base64')).toString();
console.log(inflated);
But then I get the error:
{"blocks":[{"id":"block","block":"event","args":{"items":[]},"action":"Join"},{"id":"block","block":"player_action","args":{"items":[{"item":{"id":"txt","data":{"name":"hi"}},"slot":0},{"item":{"id":"bl_tag","data":{"option":"Add spaces","tag":"Text Value Merging","action":"SendMessage","block":"player_action"}},"slot":25},{"item":{"id":"bl_tag","data":{"option":"Regular","tag":"Alignment Mode","action":"SendMessage","block":"player_action"}},"slot":26}]},"action":"SendMessage"}]}
(node:25548) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
This is what I'm trying to achieve (this is after its been base64'd)
H4sIAAAAAAAA/6VRsQrCMBD9lXKzgwg6ZHMVuqi4iJRrc8RgmpQmFaX03720RSviIE7JvXvv3rukhdy44uJBHFvQEsRQw2w8BdCVbOAaa8UsJgUqI/3UMVYE7SyTNk5b6GZfRlQG71RnI/tz1HDrkSgPt+gnMWCELJbE4FlDx47euABi3ltNNbnJAqqJzFVjtLWUia+wIM/dyBGwp1tIDmgaSlKqlbZR+NxlR1am5D0q+rrDK8pi+UOWLanGYP0MsjZa2ZLfN0mdpD9CrLq375iqufMAPTQAnOUBAAA=
(from a website)