This commit is contained in:
Tim Stallard 2017-04-03 22:08:46 +01:00
parent b07d6003ed
commit 3db4fa6841
3 changed files with 5 additions and 10 deletions

View File

@ -45,7 +45,7 @@ module.exports = {
return text
.split("")
.map(require("./util/toNum.js"))
.map((num)=>(reverseLookupTable[num]))
.map((num)=>(Number.isInteger(num) ? reverseLookupTable[num] : num))
.map(require("./util/toChar.js"))
.join("");
},

View File

@ -45,7 +45,7 @@ module.exports = {
return text
.split("")
.map(require("./util/toNum.js"))
.map((num)=>(lookupTable[num]))
.map((num)=>(Number.isInteger(num) ? lookupTable[num] : num))
.map(require("./util/toChar.js"))
.join("");
},

View File

@ -18,7 +18,7 @@ module.exports = {
execute: function({text, mapping}, elem){
mapping = mapping.toLowerCase();
var letterMapping = {};
for(var i = 0; i < (mapping.length - 1); i++){
for(var i = 0; i < (mapping.length - 1); i = i + 2){
letterMapping[mapping[i]] = mapping[i+1];
}
@ -26,15 +26,10 @@ module.exports = {
.split("")
.map((char)=>{
if(char.toLowerCase() in letterMapping){
if(char.toLowerCase() == char){
return letterMapping[char];
}
else{
return letterMapping[char.toLowerCase()].toUpperCase();
}
return letterMapping[char.toLowerCase()]
}
else{
return char;
return char.toLowerCase();
}
})
.join("");