Add new module: Convert to Emoji alphabe

This is a fun 'cipher' for kids. Converts characters to their representation in the Emoji animal alphabet, matching first letters of the animal. Can be combined with 'Generate QR Code'.
Example: 🐅 🐙 🐧   🐍 🐘🐀 🐘 🐅 
This commit is contained in:
Arnim Rupp 2020-12-26 00:46:25 +01:00
parent c9d9730726
commit ae5c7daf8b
4 changed files with 125 additions and 1 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ src/node/index.mjs
**/*.DS_Store
tests/browser/output/*
package-lock.json

View file

@ -202,7 +202,8 @@
"Decode text",
"Remove Diacritics",
"Unescape Unicode Characters",
"Convert to NATO alphabet"
"Convert to NATO alphabet",
"Convert to Emoji alphabet"
]
},
{

View file

@ -0,0 +1,89 @@
/**
* @author Arnim Rupp https://github.com/2d4d/crypto_puzzles
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
/**
* Convert to Emoji alphabet operation
*/
class ConvertToEmojiAlphabet extends Operation {
/**
* ConvertToEmojiAlphabet constructor
*/
constructor() {
super();
this.name = "Convert to Emoji alphabet";
this.module = "Default";
this.description = "This is a fun 'cipher' for kids. Converts characters to their representation in the Emoji animal alphabet, matching first letters of the animal. Can be combined with 'Generate QR Code'.";
this.infoURL = "https://en.wikipedia.org/wiki/Emoji";
this.inputType = "string";
this.outputType = "string";
this.args = [];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
return input.replace(/[a-z0-9,.\-+*#?! ]/ig, letter => {
return lookup[letter.toUpperCase()];
});
}
}
const lookup = {
"A": "🐜 ",
"B": "🐻 ",
"C": "℃ ",
"D": "🐬 ",
"E": "🐘 ",
"F": "🦊 ",
"G": "🦒 ",
"H": "🐹 ",
"I": " ",
"J": "ʝ ",
"K": "🦘 ",
"L": "🦁 ",
"M": "🐁 ",
"N": " ",
"O": "🐙 ",
"P": "🐧 ",
"Q": "🂭 ",
"R": "🐀 ",
"S": "🐍 ",
"T": "🐅 ",
"U": "ᶙ ",
"V": "✌ ",
"W": "🐋 ",
"X": "⚔️ ",
"Y": "¥ ",
"Z": "🦓 ",
"0": "🅾️ ",
"1": "🥇 ",
"2": "⚁ ",
"3": "ᗱ ",
"4": "༥ ",
"5": "⚄ ",
"6": "🃖 ",
"7": "ㇴ ",
"8": "🎱 ",
"9": "9⃣ ",
"+": " ",
"-": " ",
"#": "#️⃣ ",
"*": "✳️ ",
".": ". ",
",": ", ",
" ": " ",
"?": "<22> ",
"!": "❗️ "
};
export default ConvertToEmojiAlphabet;

View file

@ -0,0 +1,33 @@
/**
* @author Arnim Rupp https://github.com/2d4d/crypto_puzzles
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Convert to Emoji alphabet: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Convert to Emoji alphabet",
args: []
}
]
},
{
name: "Convert to Emoji alphabet: full alphabet with numbers",
input: "abcdefghijklmnopqrstuvwxyz1234567890,.-#+*-",
expectedOutput: "🐜 🐻 ℃ 🐬 🐘 🦊 🦒 🐹 ʝ 🦘 🦁 🐁 🐙 🐧 🂭 🐀 🐍 🐅 ᶙ ✌ 🐋 ⚔️ ¥ 🦓 🥇 ⚁ ᗱ ༥ ⚄ 🃖 ㇴ 🎱 9⃣ 🅾️ , . #️⃣ ✳️ ",
recipeConfig: [
{
op: "Convert to Emoji alphabet",
args: []
}
]
}
]);