Skip to content

Commit 3e1156c

Browse files
committed
[COMPRESSOR] RLE style fixed
1 parent 2b70c8c commit 3e1156c

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

Compression/RLE.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
* RLE (Run Length Encoding) is a simple form of data compression.
3-
* The basic idea is to represent repeated successive characters as a single count and character.
4-
* For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".
5-
*
6-
* @author - [ddaniel27](https://github.com/ddaniel27)
7-
*/
2+
* RLE (Run Length Encoding) is a simple form of data compression.
3+
* The basic idea is to represent repeated successive characters as a single count and character.
4+
* For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".
5+
*
6+
* @author - [ddaniel27](https://github.com/ddaniel27)
7+
*/
88

99
function Compress(str) {
1010
let compressed = ''
@@ -27,15 +27,12 @@ function Decompress(str) {
2727
let decompressed = ''
2828
let match = [...str.matchAll(/(\d+)(\D)/g)] // match all groups of digits followed by a non-digit character
2929

30-
match.forEach(item => {
30+
match.forEach((item) => {
3131
let [count, char] = [item[1], item[2]]
3232
decompressed += char.repeat(count)
3333
})
3434

35-
return decompressed
35+
return decompressed
3636
}
3737

38-
export {
39-
Compress,
40-
Decompress
41-
}
38+
export { Compress, Decompress }

0 commit comments

Comments
 (0)