Skip to content

A Gleam library implementing pieroxy's lz-string compression algorithm.

License

Notifications You must be signed in to change notification settings

eelmafia/gleamlz_string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a757017 · Oct 16, 2024

History

18 Commits
Oct 3, 2024
Oct 16, 2024
Oct 3, 2024
Sep 21, 2024
Sep 21, 2024
Oct 3, 2024
Oct 3, 2024
Oct 3, 2024
Oct 3, 2024
Oct 3, 2024

Repository files navigation

GleamLZ_String

Package Version Hex Docs

This is a Gleam implementation of the lz-string compression algorithm

Installation

gleam add gleamlz_string

Usage

import gleamlz_string
 
pub fn main() {
  let string = "Hello World!"

  //Uint8Array
  gleamlz_string.compress_to_uint8(string)
  //<<4, 133, 48, 54, 96, 246, 0, 64, 234, 144, 39, 48, 4, 192, 132, 64>>
  gleamlz_string.decompress_from_uint8(<<4, 133, 48, 54, 96, 246, 0, 64, 234, 144, 39, 48, 4, 192, 132, 64>>)
  //Ok("Hello World!)
	
  //Base64
  gleamlz_string.compress_to_base64(string)
  //"BIUwNmD2AEDqkCcwBMCEQA=="
  gleamlz_string.decompress_from_base64("BIUwNmD2AEDqkCcwBMCEQA==")
  //Ok("Hello World")
	
  //URI encoded
  gleamlz_string.compress_to_encoded_uri(string)
  //"BIUwNmD2AEDqkCcwBMCEQA$$"
  gleamlz_string.decompress_from_encoded_uri("BIUwNmD2AEDqkCcwBMCEQA$$")
  //Ok("Hello World!")
    
}

Testing

Run generate_testcases.sh first which will generate a bunch of test data using the base JavaScript lib to compare with. Once that's done run gleam test

Docs

https://hexdocs.pm/gleamlz_string/

Acknowledgements

Original LZ_String by Pieroxy

Used Michael Shapiro's elixir verson as reference

License

Apache 2.0

About

A Gleam library implementing pieroxy's lz-string compression algorithm.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published