Merge pull request #1 from artemisbot/morse-fixes

Morse fixes
This commit is contained in:
Toby Lorne 2017-02-03 22:00:55 -05:00 committed by GitHub
commit 718e1dc153
5 changed files with 172 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -93,8 +93,8 @@ var MorseCode = {
var dash = format[0]; var dash = format[0];
var dot = format[1]; var dot = format[1];
var letter_delim = MorseCode.OPTION_TABLE[args[1]]; var letterDelim = MorseCode.OPTION_TABLE[args[1]];
var word_delim = MorseCode.OPTION_TABLE[args[2]]; var wordDelim = MorseCode.OPTION_TABLE[args[2]];
input = input.split(/\r?\n/); input = input.split(/\r?\n/);
input = Array.prototype.map.call(input, function(line) { input = Array.prototype.map.call(input, function(line) {
@ -122,8 +122,8 @@ var MorseCode = {
switch(match) { switch(match) {
case "<dash>": return dash; case "<dash>": return dash;
case "<dot>": return dot; case "<dot>": return dot;
case "<ld>": return letter_delim; case "<ld>": return letterDelim;
case "<wd>": return word_delim; case "<wd>": return wordDelim;
} }
} }
); );
@ -155,22 +155,21 @@ var MorseCode = {
reverseTable(); reverseTable();
} }
var letter_delim = MorseCode.OPTION_TABLE[args[0]]; var letterDelim = MorseCode.OPTION_TABLE[args[0]];
var word_delim = MorseCode.OPTION_TABLE[args[1]]; var wordDelim = MorseCode.OPTION_TABLE[args[1]];
input = input.replace(/-|_|dash/ig, "<dash>") input = input.replace(/-|_|dash/ig, "<dash>");
input = input.replace(/\.|dot/ig, "<dot>") input = input.replace(/\.|dot/ig, "<dot>");
var words = input.split(word_delim); var words = input.split(wordDelim);
words = Array.prototype.map.call(words, function(word) { words = Array.prototype.map.call(words, function(word) {
var signals = word.split(letter_delim); var signals = word.split(letterDelim);
var letters = signals.map(function(signal) { var letters = signals.map(function(signal) {
return reversedTable[signal]; return reversedTable[signal];
}); });
var word = letters.join(""); return letters.join("");
return word;
}); });
words = words.join(" "); words = words.join(" ");

View file

@ -1,3 +1,30 @@
<<<<<<< HEAD
203 source files
<<<<<<< HEAD
<<<<<<< HEAD
104401 lines
size
136 JavaScript source files
95311 lines
3.4M size
=======
104403 lines
4.0M size
136 JavaScript source files
95313 lines
3.5M size
>>>>>>> master
=======
104466 lines
4.0M size
136 JavaScript source files
95316 lines
3.4M size
>>>>>>> master
=======
211 source files 211 source files
114840 lines 114840 lines
4.3M size 4.3M size
@ -5,14 +32,30 @@
141 JavaScript source files 141 JavaScript source files
105680 lines 105680 lines
3.7M size 3.7M size
>>>>>>> master
83 third party JavaScript source files 83 third party JavaScript source files
86258 lines 86258 lines
3.0M size 3.0M size
58 first party JavaScript source files 58 first party JavaScript source files
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
18934 lines
729K size
=======
18936 lines
728K size
>>>>>>> master
=======
18939 lines
724K size
>>>>>>> master
=======
19422 lines 19422 lines
732K size 732K size
>>>>>>> master
3.4M uncompressed JavaScript size 3.4M uncompressed JavaScript size
1.9M compressed JavaScript size 1.9M compressed JavaScript size