Xmorse is a pure javascript(~1.5kb) library for encoding / decoding morse code messages, unicode supported.
npm install xmorse
Or download dist/xmorse.min.js
source file。
Script
tag.
<script type="text/javascript" src="dist/xmorse.min.js"></script>
ES6
style.
var xmorse = require('xmorse');
//or
import xmorse from 'xmorse';
There is only 2 API named encode
, decode
.
For encode(msg, [option])
, example:
// standart morse
xmorse.encode('Hello, Xmorse!');
// unicode
xmorse.encode('コンニチハ, セカイ!');
xmorse.encode('越过长城,走向世界');
// option
var option = {
space: ' ',
long: '-',
short: '*'
};
xmorse.encode('越过长城,走向世界', option);
For decode(morse, [option])
, example:
xmorse.decode('../.-../---/...-/./-.--/---/..-/-/---/---/--...-....-...-/-..---..-.-----/---..-...--...-/-..----.--.....');
// option
var option = {
space: ' ',
long: '-',
short: '*'
};
xmorse.decode('*-** --- ***- *', option);
npm install
npm test
MIT@hustcc