Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compress a string in React Native?

Let, I have a string with 20 characters. Then, I need to compress it to a string with a length of 3 or 5 characters. Again, when I need the original string back, I should be able to decompress the compressed string and get the original string.

Is it possible to do? If yes, how to do it in REACT NATIVE? Can you please suggest me a good solution?

Thanks.

like image 766
Sennen De Almeida Avatar asked Aug 11 '26 15:08

Sennen De Almeida


1 Answers

Try like this, may help you:

var lz = require('lz-string');
let before = lz.compress("bla bla bla")
let after = lz.decompress(before)
console.log(before, before.length);// ᆁ낆J鵀 4
console.log(after, after.length); // bla bla bla 11
like image 76
Shiva Avatar answered Aug 13 '26 07:08

Shiva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!