imorse
v1.0.0
Published
imorse is a pure javascript(~1.5 kb) library for encode / decode morse code messages, unicode supported.
Downloads
43
Maintainers
Readme
IMorse
IMorse is a pure javascript(~1.5kb) library for encoding / decoding morse code messages, unicode supported.
1. Install
npm install imorse
Or download dist/imorse.min.js
source file。
2. Import It
Script
tag.
<script type="text/javascript" src="dist/imorse.min.js"></script>
ES6
style.
import { decode, encode } from 'imorse';
3. Usage & API
There is only 2 API named encode
, decode
. For encode(msg, [option])
, example:
import { decode, encode } from 'imorse';
// standart morse
encode('Hello, IMorse!');
// unicode
encode('コンニチハ, セカイ!');
encode('越过长城,走向世界');
// option
const option = {
space: ' ',
long: '-',
short: '*'
};
encode('越过长城,走向世界', option);
For decode(morse, [option])
, example:
import { decode, encode } from 'imorse';
decode('../.-../---/...-/./-.--/---/..-/-/---/---/--...-....-...-/-..---..-.-----/---..-...--...-/-..----.--.....');
// option
const option = {
space: ' ',
long: '-',
short: '*'
};
decode('*-** --- ***- *', option);
4. Test
$npm install
$npm test
5. LICENSE
Fork MIT@hustcc