- Notifications
You must be signed in to change notification settings - Fork0
kishtarn555/rekarel-binary
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This package add support for some binary formats of Karel.
It adds support for
- Reading ReKarelBinaryInpunt format (.kbi)
- Writing ReKarelBinaryInpunt format (.kbi)
- Reading MDO/KEC (.mdo .kec)
import{World}from"@rekarel/core"import{deserializeKarelBinary}from"@rekarel/binary"// Create world of arbitrary sizeconstworld=newWorld(10,10);// Read binary dataconstkbiData=awaitreadFileToArrayBuffer('world.kbi');try{// Deserializes the data into worlddeserializeKarelBinary(world,kbiData);}catch(e){console.error(e);}
import{World}from"@rekarel/core"import{KarelBinarySerializer}from"@rekarel/binary"constworld=newWorld(10,10);// Create a serializer configured to low compressionconstserializer=newKarelBinarySerializer("low");// Get an array buffer with the kbi dataconstbuffer=serializer.serialize(world);// writeArrayBufferToFile implementation is nwriteArrayBufferToFile("world.kbi",buffer);
import{World}from"@rekarel/core"import{deserializeMdoKec}from"@rekarel/binary"// Create world of arbitrary sizeconstworld=newWorld(10,10);// Read binary dataconstmdoBinary=awaitreadFileToArrayBuffer('world.mdo');// Read binary dataconstkecBinary=awaitreadFileToArrayBuffer('world.kec');// Convert buffers into Uint16 arraysconstmdo=newUint16Array(mdoBinary)constkec=newUint16Array(kecBinary)try{// Deserializes the data into worlddeserializeMdoKec(world,mdo,kec);}catch(e){console.error(e);}
About
This provides support to compress a input world into a binary format