showing results for - "compress string javascript"
Bruno
27 Feb 2017
1function en(c){var x='charCodeAt',b,e={},f=c.split(""),d=[],a=f[0],g=256;for(b=1;b<f.length;b++)c=f[b],null!=e[a+c]?a+=c:(d.push(1<a.length?e[a]:a[x](0)),e[a+c]=g,g++,a=c);d.push(1<a.length?e[a]:a[x](0));for(b=0;b<d.length;b++)d[b]=String.fromCharCode(d[b]);return d.join("")}
2
3function de(b){var a,e={},d=b.split(""),c=f=d[0],g=[c],h=o=256;for(b=1;b<d.length;b++)a=d[b].charCodeAt(0),a=h>a?d[b]:e[a]?e[a]:f+c,g.push(a),c=a.charAt(0),e[o]=f+c,o++,f=a;return g.join("")}
4
5var compressed=en("http://www.ScriptCompress.com - Simple Packer/Minify/Compress JavaScript Minify, Fixify & Prettify 75 JS Obfuscators In 1 App 25 JS Compressors (Gzip, Bzip, LZMA, etc) PHP, HTML & JS Packers In 1 App PHP Source Code Packers Text Packer HTML Packer or v2 or v3 or LZW Twitter Compress or More Words DNA & Base64 Packer (freq tool) or v2 JS JavaScript Code Golfer Encode Between Quotes Decode Almost Anything Password Protect Scripts HTML Minifier v2 or Encoder or Escaper CSS Minifier or Compressor v2 SVG Image Shrinker HTML To: SVG or SVGZ (Gzipped) HTML To: PNG or v2 2015 JS Packer v2 v3 Embedded File Generator Extreme Packer or version 2 Our Blog DemoScene JS Packer Basic JS Packer or New Version Asciify JavaScript Escape JavaScript Characters UnPacker Packed JS JavaScript Minify/Uglify Text Splitter/Chunker Twitter, Use More Characters Base64 Drag 'n Drop Redirect URL DataURI Get Words Repeated LZMA Archiver ZIP Read/Extract/Make BEAUTIFIER & CODE FIXER WHAK-A-SCRIPT JAVASCRIPT MANGLER 30 STRING ENCODERS CONVERTERS, ENCRYPTION & ENCODERS 43 Byte 1px GIF Generator Steganography PNG Generator WEB APPS VIA DATAURL OLD VERSION OF WHAK PAKr Fun Text Encrypt Our Google");
6var decompressed=de(compressed);
7
8document.writeln('<hr>'+compressed+'<hr><h1>'+compressed.length+' characters versus original '+decompressed.length+' characters.</h1><hr>'+decompressed+'<hr>');
Clara
23 Sep 2019
1function stringCompression (str) {
2  if (str.length ==0) {
3    console.log('Please enter valid string.');
4    return;
5  }
6  var output = '';
7  var count = 0;
8  for (var i = 0; i < str.length; i++) {
9    count++;
10    if (str[i] != str[i+1]) {
11      output += str[i] + count;
12      count = 0;
13    }
14  }
15  console.log(output);
16}
17
18stringCompression(''); //Please enter valid string.
19stringCompression('aaaa'); //a4
20stringCompression('aaaabbc'); //a4b2c1
21stringCompression('aaaabbcaabb'); //a4b2c1a2b2
queries leading to this page
compress a string javascriptcompressed string javascvripthow to compress strings in javascriptjavascript compressioncompress string to string javascriptjavascript file compression programjs compress sringcompression for your javascript string compression jscompress strings jsrandom string compression javascriptcompressed string javascriptloseless string compression javascriptjs compressioncompress a string in jsjs compressorcompressing strings in javascriptcompression javascript basicsstring compression problem in javascriptcompress string javascriptstring compressor javascriptbetter compression in javascriptstring compression javascriptjs string compressionwrite string compression function in javascriptstring compression in jscompres long string to short string javascriptjavascript text compressionstored compressed string javascriptcompressing a large string javascriptjs compress stringsjs text compressionjavascript string compression algorithmjs compress charactersdatetime zip string jsjs func compressionzip string to string in jsjavascript compression ratiostring compression in javascriptstring compression algorithm javascriptjavascript compression functionjavascript compress ling stringscompression string javascriptjs func compression onlinecompress text javascriptjavascript string compressioncompressing strings javascriptsimple string compression javascriptcompressione javascriptjs browser compres stringjs compress string with letterscomplete the function compressedstring javascriptjs string compresscompression javascriptcompress strings javascriptjs compressed stringstring to string compression javascriptonline javascript string compressorjs string comptessjavascript string lzw compressionjavascript zip string in memoryjavascript string compresscompress string in javascriptin js file compressioncompress string in jsbest way to compress string in javascriptcompress the string javascriptstring compression ii javascriptcompression function javascriptjs compress strings onlinecompression rle javascriptcompress string jsjs compress stringjavascript compress stringjavascript compression onlinehow to compress strings jshow to compress a string in javascriptcompress text in jsstring compression javasriptjavascript quick compress a string and decompresslz string encodecompress string javascript