File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
src/compression/runlength Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ var runLengthEncoding = (function () {
10
10
11
11
'use strict' ;
12
12
13
+ /**
14
+ * Convers a given string to sequence of numbers
15
+ * This takes O(n).
16
+ */
13
17
function convertToAscii ( str ) {
14
18
var result = '' ,
15
19
currentChar = '' ,
@@ -25,7 +29,11 @@ var runLengthEncoding = (function () {
25
29
}
26
30
return result ;
27
31
}
28
-
32
+
33
+ /**
34
+ * Encodes the binary string to run-length encoding.
35
+ * Takes O(n^2).
36
+ */
29
37
function runLength ( vector ) {
30
38
var result = '' ,
31
39
zeros = 0 ,
@@ -48,7 +56,11 @@ var runLengthEncoding = (function () {
48
56
}
49
57
return result ;
50
58
}
51
-
59
+
60
+ /**
61
+ * Accepts a string and returns it's run-length encoded binary representation.
62
+ * Takes O(n^2).
63
+ */
52
64
return function ( str ) {
53
65
var asciiString = convertToAscii ( str ) ;
54
66
return runLength ( asciiString ) ;
You can’t perform that action at this time.
0 commit comments