Skip to content

SurakartaArcade/surakarta-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compress Surakarta games into one string

This small library can be used to convert a Surakarta game into a string that can be later converted back into a Surakarta game. It is helpful when you need to send a state over the network or store it on disk.

Usage

Compressor

You can import the compressor functions as follows:

import { Compressor, compress, decompress } from 'surakarta-store';

Compressor.compress(...);
Compressor.decompress(...);

compress

compress(state: Surakarta | number[36]): number[3]

Compresses a Surakarta game or ones state into an array of just 3 number. These numbers can be stored as 32-bit integers on disk.

decompress

decompress(values: number[3]): number[36]

Generates back the states of the Surakarta game compressed into values. You must create the actual Surakarta instance yourself.

Bundler

The bundler is useful when you need to compress multiple (only one is allowed too) Surakarta games. It produces a JSON string holding the information.

You can import the bundler functions as follows:

import { Bundler, bundle, unbundle } from 'surkarta-store';

Bundler.bundle(...);
Bundler.unbundle(...);

bundle

bundle(states: Array<Surakarta | number[36]>): string

Bundles all the Surakarta games/states into one string.

unbundle(string): Array<number[36]>

Unbundles all the Surakarta games into an array of states. You must create each Surakarta instance yourself.

About

Store compressed Surakarta game states to read them later!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published