1

Hello I am a high school student who is new to coding and I am working on a science fair project. For my project I am required to use a compression algorithm, due to my lack of knowledge I am restricted to javascript. I found a compression algorithm in jslzjb but the algorithm compresses the message into a byte array when I need it in strings.

Is there a way to compress a message into strings using javascript, by the way I need the compression algorithm to be lossless.

Thanks

11
  • Perhaps you can just convert your byte array into a string of some sort? Commented Oct 23, 2012 at 1:48
  • 3
    A simple way to handle your problem is to encode binary data using Base64, although this introduces an overhead of 33%. Commented Oct 23, 2012 at 1:50
  • I actually tried that, what would happen is I would use the toString function however all this would cause is an expansion of the array actually causing the message to actually get bigger in size. I also tried using base64 given by jslzjb it also resulted in the message increasing in size slightly. Commented Oct 23, 2012 at 1:51
  • That's just the nature of the beast. Why are you restricted to JS again? Commented Oct 23, 2012 at 1:59
  • I am new to coding, all I have learned is javascript. What I am looking for is a way of compressing into strings. Can I not do that in Javascript? Would I need to use a different language? Commented Oct 23, 2012 at 2:06

1 Answer 1

2

The following compression algorithm is written by Curto in Javascript, and works directly on streams : https://github.com/pierrec/node-lz4

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.