Skip to content
/ xmorse Public

🌞 ~1.5Kb morse code library for all. 一个支持 Unicode 中文摩斯密码编码的 Javascript 库。

License

Notifications You must be signed in to change notification settings

hustcc/xmorse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xmorse

Xmorse is a pure javascript(~1.5kb) library for encoding / decoding morse code messages, unicode supported.

中文说明文档 | Online DEMO 地址

Build Status npm npm npm

1. Install

npm install xmorse

Or download dist/xmorse.min.js source file。

2. Import It

  • Script tag.
<script type="text/javascript" src="dist/xmorse.min.js"></script>
  • ES6 style.
var xmorse = require('xmorse');

//or

import xmorse from 'xmorse';

3. Usage & API

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);

4. Test

npm install

npm test

5. LICENSE

MIT@hustcc