morse-node
v0.1.1
Published
Encode strings to Morse code, decode strings from Morse code.
Downloads
223
Readme
Morse Node
A very tiny, dependency-free Morse code encoder and decoder. Currently supports the ITU standard.
Install
- Not yet available.
npm install morse-node
Getting Started
Setup API
var morse = require('morse-node').create("ITU");
Encoding
- All alphanumeric characters are accepted, available punctuation includes everything inside the brackets [ . , ? ' ! / ( ) & : ; = + - _ " $ @ ].
var msg = morse.encode('The quick brown fox jumped over the lazy dog.');
Decoding
- Letters are seperated by a single space.
- Words are seperated by a forward slash " / ".
var msg = morse.decode("- .... ./--.- ..- .. -.-. -.-/-... .-. --- .-- -./..-. --- -..-/.--- ..- -- .--. . -../--- ...- . .-./- .... ./.-.. .- --.. -.--/-.. --- --. .-.-.-");
Example
example.js
var morse = require('./morse-node').create();
var msg = morse.encode('Pack my box with five dozen liquor jugs!');
console.log(msg);
console.log(morse.decode(msg));
Output
.--. .- -.-. -.- / -- -.-- / -... --- -..- / .-- .. - .... / ..-. .. ...- . / -.. --- --.. . -. / .-.. .. --.- ..- --- .-. / .--- ..- --. ... -.-.--
pack my box with five dozen liquor jugs!