morsejs
A morse code translation library written in JavaScript
Working implementation of morsejs
Translation
morsejs:translate will translate a given String to an Array of Numbers found in the signal enumeration (by default: 0
,1
).
The return structure is formated so that it is similar to the transmission format of a morse message. This means that it includes the spacing between symbol signals, the symbols themselves, and words. See transmission of morse code on Wikipedia for a better explanation.
By default, this library transmits 0
for any padding between signals, symbols, or words. Similarly, it sends 0
for a short signal and 3 0
for a long signal.
Consider the transmission of "SOS":
1 2 3
123456789012345678901234567890
-_-_-___---_---_---___-_-_-
morsejs would actually return:
[ 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0]
Note: there is plus 0 in the end
Installation
Binary
npm install -g morsejs
Dependency
npm install --save morsejs
Usage
CLI
morsejs hello world
JS
If you just want to plainly translate a message, you can just use translate
var message = morsejs;
All the other plugins won't work.