Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
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.
$ npm install morsify --save
$ yarn add morsify
var morsify = require('morsify');
var encoded = morsify.encode('SOS'); // .../---/...
var decoded = morsify.decode('.../---/...'); // S O S
var audio = morsify.audio('SOS'), oscillator = audio.oscillator; // OscillatorNode
audio.play(); // play audio
audio.stop(); // stop audio
Or alternatively, you can also use the library directly with including the source file.
<script src="https://rawgit.com/ozdemirburak/morsify/master/index.js"></script>
<script>
var encoded = morsify.encode('SOS'); // .../---/...
var decoded = morsify.decode('.../---/...'); // S O S
var audio = morsify.audio('SOS'), oscillator = audio.oscillator; // OscillatorNode
audio.play(); // play audio
audio.stop(); // stop audio
</script>
You can customize the dash, dot or space characters and specify the alphabet with the priority option for an accurate encoding and decoding.
What priority option does is, gives direction to the plugin to start to searching for the given character set first.
Set the priority option according to the list below.
var cyrillic = morsify.encode('Ленинград', { priority: 5 }) // .-.././-./../-./--./.-./.-/-..
var greek = morsify.decode('.../.-/--./.-/.--./.--', { priority: 6 }) // Σ Α Γ Α Π Ω
var hebrew = morsify.decode('––– –... ––– –. ––. .. .–.. –––', { dash: '–', dot: '.', space: ' ', priority: 7 }) // ה ב ה נ ג י ל ה
var arabicAudio = morsify.audio('البُراق', { // generates the morse .-/.-../-.../.-./.-/--.- then generates the audio from it
unit: 0.1, // period of one unit, in seconds, 1.2 / c where c is speed of transmission, in words per minute
oscillator: {
type: 'sine', // sine, square, sawtooth, triangle
frequency: 500, // value in hertz
onended: function () { // event that fires when the tone has stopped playing
console.log('ended');
},
}
}), oscillator = arabicAudio.oscillator; // OscillatorNode
arabicAudio.play(); // will start playing morse audio
arabicAudio.stop(); // will stop playing morse audio
Contributions are welcome.
Currently, as a major drawback, Chinese characters are missing. Someone with the knowledge of Chinese telegraph code can help to implement it. Also someone who is proficient in Thai can help to include Thai alphabet.
The MIT License (MIT). Please see License File for more information.
FAQs
Morse code translator, Morse encoder and decoder which can also generate audio.
The npm package morsify receives a total of 13 weekly downloads. As such, morsify popularity was classified as not popular.
We found that morsify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.