File tree Expand file tree Collapse file tree
src/compression/runlength Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ var runLengthEncoding = (function () {
1010
1111 'use strict' ;
1212
13+ /**
14+ * Convers a given string to sequence of numbers
15+ * This takes O(n).
16+ */
1317 function convertToAscii ( str ) {
1418 var result = '' ,
1519 currentChar = '' ,
@@ -25,7 +29,11 @@ var runLengthEncoding = (function () {
2529 }
2630 return result ;
2731 }
28-
32+
33+ /**
34+ * Encodes the binary string to run-length encoding.
35+ * Takes O(n^2).
36+ */
2937 function runLength ( vector ) {
3038 var result = '' ,
3139 zeros = 0 ,
@@ -48,7 +56,11 @@ var runLengthEncoding = (function () {
4856 }
4957 return result ;
5058 }
51-
59+
60+ /**
61+ * Accepts a string and returns it's run-length encoded binary representation.
62+ * Takes O(n^2).
63+ */
5264 return function ( str ) {
5365 var asciiString = convertToAscii ( str ) ;
5466 return runLength ( asciiString ) ;
You can’t perform that action at this time.
0 commit comments