Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

morsify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morsify - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

2

dist/morsify.min.js

@@ -1,1 +0,1 @@

!function(e,n,t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define(t):n.morsify=t()}(0,this,function(){var e={1:{A:"01",B:"1000",C:"1010",D:"100",E:"0",F:"0010",G:"110",H:"0000",I:"00",J:"0111",K:"101",L:"0100",M:"11",N:"10",O:"111",P:"0110",Q:"1101",R:"010",S:"000",T:"1",U:"001",V:"0001",W:"011",X:"1001",Y:"1011",Z:"1100"},2:{0:"11111",1:"01111",2:"00111",3:"00011",4:"00001",5:"00000",6:"10000",7:"11000",8:"11100",9:"11110"},3:{".":"010101",",":"110011","?":"001100","'":"011110","!":"101011","/":"10010","(":"10110",")":"101101","&":"01000",":":"111000",";":"101010","=":"10001","+":"01010","-":"100001",_:"001101",'"':"010010",$:"0001001","@":"011010","¿":"00101","¡":"110001"},4:{"Ã":"01101","Á":"01101","Å":"01101","À":"01101","Â":"01101","Ä":"0101","Ą":"0101","Æ":"0101","Ç":"10100","Ć":"10100","Ĉ":"10100","Č":"110","Đ":"00100","Ð":"00110","È":"01001","Ë":"00100","Ę":"00100","É":"00100","Ê":"10010","Ğ":"11010","Ĝ":"11010","Ĥ":"1111","İ":"01001","Ï":"10011","Ì":"01110","Ĵ":"01110","Ł":"01001","Ń":"11011","Ñ":"11011","Ó":"1110","Ò":"1110","Ö":"1110","Ô":"1110","Ø":"1110","Ś":"0001000","Ş":"01100","Ș":"1111","Š":"1111","Ŝ":"00010","ß":"000000","Þ":"01100","Ü":"0011","Ù":"0011","Ŭ":"0011","Ž":"11001","Ź":"110010","Ż":"11001"},5:{"А":"01","Б":"1000","В":"011","Г":"110","Д":"100","Е":"0","Ж":"0001","З":"1100","И":"00","Й":"0111","К":"101","Л":"0100","М":"11","Н":"10","О":"111","П":"0110","Р":"010","С":"000","Т":"1","У":"001","Ф":"0010","Х":"0000","Ц":"1010","Ч":"1110","Ш":"1111","Щ":"1101","Ъ":"11011","Ы":"1011","Ь":"1001","Э":"00100","Ю":"0011","Я":"0101"},6:{"Α":"01","Β":"1000","Γ":"110","Δ":"100","Ε":"0","Ζ":"1100","Η":"0000","Θ":"1010","Ι":"00","Κ":"101","Λ":"0100","Μ":"11","Ν":"10","Ξ":"1001","Ο":"111","Π":"0110","Ρ":"010","Σ":"000","Τ":"1","Υ":"1011","Φ":"0010","Χ":"1111","Ψ":"1101","Ω":"011"},7:{"א":"01","ב":"1000","ג":"110","ד":"100","ה":"111","ו":"0","ז":"1100","ח":"0000","ט":"001","י":"00","כ":"101","ל":"0100","מ":"11","נ":"10","ס":"1010","ע":"0111","פ":"0110","צ":"011","ק":"1101","ר":"010","ש":"000","ת":"1"},8:{"ا":"01","ب":"1000","ت":"1","ث":"1010","ج":"0111","ح":"0000","خ":"111","د":"100","ذ":"1100","ر":"010","ز":"1110","س":"000","ش":"1111","ص":"1001","ض":"0001","ط":"001","ظ":"1011","ع":"0101","غ":"110","ف":"0010","ق":"1101","ك":"101","ل":"0100","م":"11","ن":"10","ه":"00100","و":"011","ي":"00","ﺀ":"0"},9:{"ا":"01","ب":"1000","پ":"0110","ت":"1","ث":"1010","ج":"0111","چ":"1110","ح":"0000","خ":"1001","د":"100","ذ":"0001","ر":"010","ز":"1100","ژ":"110","س":"000","ش":"1111","ص":"0101","ض":"00100","ط":"001","ظ":"1011","ع":"111","غ":"0011","ف":"0010","ق":"111000","ک":"101","گ":"1101","ل":"0100","م":"11","ن":"10","و":"011","ه":"0","ی":"00"},10:{"ア":"11011","カ":"0100","サ":"10101","タ":"10","ナ":"010","ハ":"1000","マ":"1001","ヤ":"011","ラ":"000","ワ":"101","イ":"01","キ":"10100","シ":"11010","チ":"0010","ニ":"1010","ヒ":"11001","ミ":"00101","リ":"110","ヰ":"01001","ウ":"001","ク":"0001","ス":"11101","ツ":"0110","ヌ":"0000","フ":"1100","ム":"1","ユ":"10011","ル":"10110","ン":"01010","エ":"01000","ケ":"1011","セ":"01110","テ":"01011","ネ":"1101","ヘ":"0","メ":"10001","レ":"111","ヱ":"01100","、":"010101","オ":"10111","コ":"1111","ソ":"1110","ト":"00100","ノ":"0011","ホ":"100","モ":"10010","ヨ":"11","ロ":"0101","ヲ":"0111","。":"010100"},11:{"ㄱ":"0100","ㄴ":"0010","ㄷ":"1000","ㄹ":"0001","ㅁ":"11","ㅂ":"011","ㅅ":"110","ㅇ":"101","ㅈ":"0110","ㅊ":"1010","ㅋ":"1001","ㅌ":"1100","ㅍ":"111","ㅎ":"0111","ㅏ":"0","ㅑ":"00","ㅓ":"1","ㅕ":"000","ㅗ":"01","ㅛ":"10","ㅜ":"0000","ㅠ":"010","ㅡ":"100","ㅣ":"001"},12:{"ก":"110","ข":"1010","ค":"101","ง":"10110","จ":"10010","ฉ":"1111","ช":"1001","ซ":"1100","ญ":"0111","ด":"100","ต":"1","ถ":"10100","ท":"10011","น":"10","บ":"1000","ป":"0110","ผ":"1101","ฝ":"10101","พ":"01100","ฟ":"0010","ม":"11","ย":"1011","ร":"010","ล":"0100","ว":"011","ส":"000","ห":"0000","อ":"10001","ฮ":"11011","ฤ":"01011","ะ":"01000","า":"01","ิ":"00100","ี":"00","ึ":"00110","ื":"0011","ุ":"00101","ู":"1110","เ":"0","แ":"0101","ไ":"01001","โ":"111","ำ":"00010","่":"001","้":"0001","๊":"11000","๋":"01010","ั":"01101","็":"11100","์":"11001","ๆ":"10111","ฯ":"11010"}},n=function(n,t){var i=o(n),r={};for(var a in e){r[a]={};for(var c in e[a])r[a][c]=e[a][c].replace(/0/g,i.dot).replace(/1/g,i.dash)}return!0!==t&&delete r[0],r},t=function(e){var t={},o=n(e,!0);for(var i in o)for(var r in o[i])void 0===t[o[i][r]]&&(t[o[i][r]]=r);return t},o=function(n){return n=n||{},n.oscillator=n.oscillator||{},n={dash:n.dash||"-",dot:n.dot||".",space:n.space||"/",invalid:n.invalid||"#",priority:n.priority||1,unit:n.unit||.08,oscillator:{type:n.oscillator.type||"sine",frequency:n.oscillator.frequency||500,onended:n.oscillator.onended||null}},e[0]=e[n.priority],n},i=function(n,t){var i=o(t);return n.replace(/\s+/g,"").toLocaleUpperCase().split("").map(function(n){for(var t in e)if(void 0!==e[t][n])return e[t][n];return i.invalid}).join(i.space).replace(/0/g,i.dot).replace(/1/g,i.dash)};return{characters:n,decode:function(e,n){var i=o(n),r=t(i);return e.split(i.space).map(function(e){return r[e]||i.invalid}).join(" ").replace(/\s+/g," ")},encode:i,audio:function(e,n){var t=o(n),r=i(e,n),a=new(window.AudioContext||window.webkitAudioContext),c=a.currentTime,l=a.createOscillator(),u=a.createGain();l.type=t.oscillator.type,l.frequency.value=t.oscillator.frequency,l.onended=t.oscillator.onended,u.gain.setValueAtTime(0,c);for(var s=function(e){u.gain.setValueAtTime(1,c),c+=e*t.unit},d=function(e){u.gain.setValueAtTime(0,c),c+=e*t.unit},f=0;f<=r.length;f++)r[f]===t.space?d(7):r[f]===t.dot?(s(1),d(1)):r[f]===t.dash?(s(3),d(1)):d(3);return l.connect(u),u.connect(a.destination),{play:function(){l.start(),l.stop(c)},stop:function(){l.stop()},context:a,oscillator:l}}}});
!function(e,n,t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define(t):n.morsify=t()}(0,this,function(){var e={1:{A:"01",B:"1000",C:"1010",D:"100",E:"0",F:"0010",G:"110",H:"0000",I:"00",J:"0111",K:"101",L:"0100",M:"11",N:"10",O:"111",P:"0110",Q:"1101",R:"010",S:"000",T:"1",U:"001",V:"0001",W:"011",X:"1001",Y:"1011",Z:"1100"},2:{0:"11111",1:"01111",2:"00111",3:"00011",4:"00001",5:"00000",6:"10000",7:"11000",8:"11100",9:"11110"},3:{".":"010101",",":"110011","?":"001100","'":"011110","!":"101011","/":"10010","(":"10110",")":"101101","&":"01000",":":"111000",";":"101010","=":"10001","+":"01010","-":"100001",_:"001101",'"':"010010",$:"0001001","@":"011010","¿":"00101","¡":"110001"},4:{"Ã":"01101","Á":"01101","Å":"01101","À":"01101","Â":"01101","Ä":"0101","Ą":"0101","Æ":"0101","Ç":"10100","Ć":"10100","Ĉ":"10100","Č":"110","Đ":"00100","Ð":"00110","È":"01001","Ë":"00100","Ę":"00100","É":"00100","Ê":"10010","Ğ":"11010","Ĝ":"11010","Ĥ":"1111","İ":"01001","Ï":"10011","Ì":"01110","Ĵ":"01110","Ł":"01001","Ń":"11011","Ñ":"11011","Ó":"1110","Ò":"1110","Ö":"1110","Ô":"1110","Ø":"1110","Ś":"0001000","Ş":"01100","Ș":"1111","Š":"1111","Ŝ":"00010","ß":"000000","Þ":"01100","Ü":"0011","Ù":"0011","Ŭ":"0011","Ž":"11001","Ź":"110010","Ż":"11001"},5:{"А":"01","Б":"1000","В":"011","Г":"110","Д":"100","Е":"0","Ж":"0001","З":"1100","И":"00","Й":"0111","К":"101","Л":"0100","М":"11","Н":"10","О":"111","П":"0110","Р":"010","С":"000","Т":"1","У":"001","Ф":"0010","Х":"0000","Ц":"1010","Ч":"1110","Ш":"1111","Щ":"1101","Ъ":"11011","Ы":"1011","Ь":"1001","Э":"00100","Ю":"0011","Я":"0101"},6:{"Α":"01","Β":"1000","Γ":"110","Δ":"100","Ε":"0","Ζ":"1100","Η":"0000","Θ":"1010","Ι":"00","Κ":"101","Λ":"0100","Μ":"11","Ν":"10","Ξ":"1001","Ο":"111","Π":"0110","Ρ":"010","Σ":"000","Τ":"1","Υ":"1011","Φ":"0010","Χ":"1111","Ψ":"1101","Ω":"011"},7:{"א":"01","ב":"1000","ג":"110","ד":"100","ה":"111","ו":"0","ז":"1100","ח":"0000","ט":"001","י":"00","כ":"101","ל":"0100","מ":"11","נ":"10","ס":"1010","ע":"0111","פ":"0110","צ":"011","ק":"1101","ר":"010","ש":"000","ת":"1"},8:{"ا":"01","ب":"1000","ت":"1","ث":"1010","ج":"0111","ح":"0000","خ":"111","د":"100","ذ":"1100","ر":"010","ز":"1110","س":"000","ش":"1111","ص":"1001","ض":"0001","ط":"001","ظ":"1011","ع":"0101","غ":"110","ف":"0010","ق":"1101","ك":"101","ل":"0100","م":"11","ن":"10","ه":"00100","و":"011","ي":"00","ﺀ":"0"},9:{"ا":"01","ب":"1000","پ":"0110","ت":"1","ث":"1010","ج":"0111","چ":"1110","ح":"0000","خ":"1001","د":"100","ذ":"0001","ر":"010","ز":"1100","ژ":"110","س":"000","ش":"1111","ص":"0101","ض":"00100","ط":"001","ظ":"1011","ع":"111","غ":"0011","ف":"0010","ق":"111000","ک":"101","گ":"1101","ل":"0100","م":"11","ن":"10","و":"011","ه":"0","ی":"00"},10:{"ア":"11011","カ":"0100","サ":"10101","タ":"10","ナ":"010","ハ":"1000","マ":"1001","ヤ":"011","ラ":"000","ワ":"101","イ":"01","キ":"10100","シ":"11010","チ":"0010","ニ":"1010","ヒ":"11001","ミ":"00101","リ":"110","ヰ":"01001","ウ":"001","ク":"0001","ス":"11101","ツ":"0110","ヌ":"0000","フ":"1100","ム":"1","ユ":"10011","ル":"10110","ン":"01010","エ":"01000","ケ":"1011","セ":"01110","テ":"01011","ネ":"1101","ヘ":"0","メ":"10001","レ":"111","ヱ":"01100","、":"010101","オ":"10111","コ":"1111","ソ":"1110","ト":"00100","ノ":"0011","ホ":"100","モ":"10010","ヨ":"11","ロ":"0101","ヲ":"0111","。":"010100"},11:{"ㄱ":"0100","ㄴ":"0010","ㄷ":"1000","ㄹ":"0001","ㅁ":"11","ㅂ":"011","ㅅ":"110","ㅇ":"101","ㅈ":"0110","ㅊ":"1010","ㅋ":"1001","ㅌ":"1100","ㅍ":"111","ㅎ":"0111","ㅏ":"0","ㅑ":"00","ㅓ":"1","ㅕ":"000","ㅗ":"01","ㅛ":"10","ㅜ":"0000","ㅠ":"010","ㅡ":"100","ㅣ":"001"},12:{"ก":"110","ข":"1010","ค":"101","ง":"10110","จ":"10010","ฉ":"1111","ช":"1001","ซ":"1100","ญ":"0111","ด":"100","ต":"1","ถ":"10100","ท":"10011","น":"10","บ":"1000","ป":"0110","ผ":"1101","ฝ":"10101","พ":"01100","ฟ":"0010","ม":"11","ย":"1011","ร":"010","ล":"0100","ว":"011","ส":"000","ห":"0000","อ":"10001","ฮ":"11011","ฤ":"01011","ะ":"01000","า":"01","ิ":"00100","ี":"00","ึ":"00110","ื":"0011","ุ":"00101","ู":"1110","เ":"0","แ":"0101","ไ":"01001","โ":"111","ำ":"00010","่":"001","้":"0001","๊":"11000","๋":"01010","ั":"01101","็":"11100","์":"11001","ๆ":"10111","ฯ":"11010"}},n=function(n,t){var o=i(n),r={};for(var a in e){r[a]={};for(var c in e[a])r[a][c]=e[a][c].replace(/0/g,o.dot).replace(/1/g,o.dash)}return!0!==t&&delete r[0],r},t=function(e){var t={},o=n(e,!0);for(var r in o)for(var i in o[r])void 0===t[o[r][i]]&&(t[o[r][i]]=i);return t},o=function(e){for(var n=[],t=0;t<e.length;t++)n[t]=("00"+e.charCodeAt(t).toString(16)).slice(-4);return parseInt(n.join(""),16).toString(2)},r=function(e,n){return e=e.replace(new RegExp("\\"+n.dot,"g"),"0").replace(new RegExp("\\"+n.dash,"g"),"1"),e=parseInt(e,2),isNaN(e)?n.invalid:decodeURIComponent(JSON.parse('"\\u'+e.toString(16)+'"'))},i=function(n){return n=n||{},n.oscillator=n.oscillator||{},n={dash:n.dash||"-",dot:n.dot||".",space:n.space||"/",invalid:n.invalid||"#",priority:n.priority||1,unit:n.unit||.08,oscillator:{type:n.oscillator.type||"sine",frequency:n.oscillator.frequency||500,onended:n.oscillator.onended||null}},e[0]=e[n.priority],n},a=function(n,t){var r=i(t);return n.replace(/\s+/g,"").toLocaleUpperCase().split("").map(function(n){for(var t in e)if(void 0!==e[t]&&void 0!==e[t][n])return e[t][n];return 13===parseInt(r.priority)?o(n):r.invalid}).join(r.space).replace(/0/g,r.dot).replace(/1/g,r.dash)};return{characters:n,decode:function(e,n){var o=i(n),a=t(o);return e.split(o.space).map(function(e){return void 0!==a[e]?a[e]:13===parseInt(o.priority)?r(e,o):o.invalid}).join(" ").replace(/\s+/g," ")},encode:a,audio:function(e,n){var t=i(n),o=a(e,n),r=new(window.AudioContext||window.webkitAudioContext),c=r.currentTime,l=r.createOscillator(),s=r.createGain();l.type=t.oscillator.type,l.frequency.value=t.oscillator.frequency,l.onended=t.oscillator.onended,s.gain.setValueAtTime(0,c);for(var u=function(e){s.gain.setValueAtTime(1,c),c+=e*t.unit},d=function(e){s.gain.setValueAtTime(0,c),c+=e*t.unit},p=0;p<=o.length;p++)o[p]===t.space?d(7):o[p]===t.dot?(u(1),d(1)):o[p]===t.dash?(u(3),d(1)):d(3);return l.connect(s),s.connect(r.destination),{play:function(){l.start(),l.stop(c)},stop:function(){l.stop()},context:r,oscillator:l}}}});
{
"name": "morsify",
"version": "0.4.0",
"version": "0.5.0",
"description": "Morse code translator and decoder which also generates audio.",

@@ -14,2 +14,6 @@ "keywords": [

"morse translator",
"morse code translator",
"samuel morse",
"codigo morse",
"морзе",
"morsify"

@@ -16,0 +20,0 @@ ],

@@ -6,3 +6,3 @@ # morsify

Morse code encoder and decoder with no dependencies supports Latin, Cyrillic, Greek, Hebrew,
Arabic, Persian, Japanese, and Korean characters with audio generation functionality using the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API).
Arabic, Persian, Japanese, Korean, Thai, and Unicode (Chinese and the others) characters with audio generation functionality using the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API).

@@ -74,7 +74,9 @@ Live demo can be found at [morsify.net](https://morsify.net).

- 12 => Thai
- 13 => Unicode (Chinese and the others)
```js
var cyrillic = morsify.encode('Ленинград', { priority: 5 }) // .-.././-./../-./--./.-./.-/-..
var greek = morsify.decode('.../.-/--./.-/.--./.--', { priority: 6 }) // Σ Α Γ Α Π Ω
var hebrew = morsify.decode('––– –... ––– –. ––. .. .–.. –––', { dash: '–', dot: '.', space: ' ', priority: 7 }) // ה ב ה נ ג י ל ה
var cyrillic = morsify.encode('Ленинград', { priority: 5 }); // .-.././-./../-./--./.-./.-/-..
var greek = morsify.decode('.../.-/--./.-/.--./.--', { priority: 6 }); // Σ Α Γ Α Π Ω
var hebrew = morsify.decode('––– –... ––– –. ––. .. .–.. –––', { dash: '–', dot: '.', space: ' ', priority: 7 }); // ה ב ה נ ג י ל ה
var chinese = morsify.encode('你好', { priority: 13 }); // -..----.--...../-.--..-.-----.-
var characters = morsify.characters({ dash: '–', dot: '•' }); // {'1': {'A': '•–', ...}, ..., '11': {'ㄱ': '•–••', ...}}

@@ -101,6 +103,2 @@ var arabicAudio = morsify.audio('البُراق‎‎', { // generates the morse .-/.-../-.../.-./.-/--.- then generates the audio from it

Currently, as a major drawback, Chinese characters are missing. Someone with the knowledge of
[Chinese telegraph code](https://en.wikipedia.org/wiki/Chinese_telegraph_code) can help to implement it. Also someone who is proficient in Thai can help
to include [Thai alphabet](https://th.wikipedia.org/wiki/รหัสมอร์ส).
## Generating Minified Files

@@ -107,0 +105,0 @@

@@ -103,3 +103,2 @@ ;(function (name, root, factory) {

'ๆ': '10111', 'ฯ': '11010',
// duplicates
// 'ฃ': '1010', => duplicated with ข | 'ฅ': '101', 'ฆ': '101', => duplicated with ค | 'ฎ': '100', => duplicated with ด

@@ -138,2 +137,19 @@ // 'ฏ': '1', => duplicated with ต | 'ฐ': '10100', => duplicated with ถ | 'ธ': '10011', 'ฑ': '10011', 'ฒ': '10011', => duplicated with ท

var unicodeToMorse = function (character) {
var ch = [];
for (var i = 0; i < character.length; i++) {
ch[i] = ('00' + character.charCodeAt(i).toString(16)).slice(-4);
}
return parseInt(ch.join(''), 16).toString(2);
};
var unicodeToHex = function (morse, options) {
morse = morse.replace(new RegExp('\\' + options.dot, 'g'), '0').replace(new RegExp('\\' + options.dash, 'g'), '1');
morse = parseInt(morse, 2);
if (isNaN(morse)) {
return options.invalid;
}
return decodeURIComponent(JSON.parse('"'+ '\\u' + morse.toString(16) +'"'));
};
var getOptions = function (options) {

@@ -163,7 +179,7 @@ options = options || {};

for (var set in characters) {
if (typeof characters[set][character] !== 'undefined') {
if (typeof characters[set] !== 'undefined' && typeof characters[set][character] !== 'undefined') {
return characters[set][character];
}
}
return options.invalid;
return parseInt(options.priority) === 13 ? unicodeToMorse(character) : options.invalid;
}).join(options.space).replace(/0/g, options.dot).replace(/1/g, options.dash);

@@ -175,3 +191,6 @@ };

return morse.split(options.space).map(function(characters) {
return swapped[characters] || options.invalid;
if (typeof swapped[characters] !== 'undefined') {
return swapped[characters];
}
return parseInt(options.priority) === 13 ? unicodeToHex(characters, options) : options.invalid;
}).join(' ').replace(/\s+/g, ' ');

@@ -178,0 +197,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc