nbt-js icon indicating copy to clipboard operation
nbt-js copied to clipboard

Added writeCompressed, shrinkCompound and growCompound

Open josefandersson opened this issue 5 years ago • 2 comments
trafficstars

Added methods:

  • nbt.writeCompressed - uses nbt.writeUncompressed but also gzips the data if zlib exists.
  • nbt.shrinkCompound - destructively shrinks named compound data objects into a more compact compound object, disregarding data types. Makes it way easier to maneuver the nbt data.
  • nbt.growCompound - attempts to redo shrinkCompound, works alright for the most part but some data types can be mixed up (eg byte/short/int/long)

Also changed how zlib is imported by adding nbt.gunzip and nbt.gzip which can be overwritten if the user wants to use another gzip library (useful for websites). By default these two functions while primarily try to load zlib, secondly pako, then error as before. Built in support for pako this library easier to use for websites.

Also added a few more examples in /example.

josefandersson avatar Jan 19 '20 22:01 josefandersson

This is a great addition and I apologise for not taking action on this PR. As I'll explain on in a readme update I'm not going to close down this repo but I'll leave this open for the benefit of whoever might find it useful.

sjmulder avatar Mar 19 '24 10:03 sjmulder

This is a great addition and I apologise for not taking action on this PR. As I'll explain on in a readme update I'm not going to close down this repo but I'll leave this open for the benefit of whoever might find it useful.

It's been over four years, what brought you here now... 😂

josefandersson avatar Mar 19 '24 10:03 josefandersson