[go: up one dir, main page]

xmorse
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Xmorse

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

中文说明文档 | Online DEMO 地址

Build Status Coverage 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.
import { decode, encode } from 'xmorse';

3. Usage & API

There is only 2 API named encode, decode. For encode(msg, [option]), example:

import { decode, encode } from 'xmorse';
// standart morse
encode('Hello, Xmorse!');
  
// unicode
encode('コンニチハ, セカイ!');
encode('越过长城,走向世界');
 
// option
const option = {
  space: ' ',
  long: '-',
  short: '*'
};
encode('越过长城,走向世界', option);

For decode(morse, [option]), example:

import { decode, encode } from 'xmorse';
decode('../.-../---/...-/./-.--/---/..-/-/---/---/--...-....-...-/-..---..-.-----/---..-...--...-/-..----.--.....');
 
// option
const option = {
  space: ' ',
  long: '-',
  short: '*'
};
decode('*-** --- ***- *', option);

4. Test

$npm install
 
$npm test

5. LICENSE

MIT@hustcc

Package Sidebar

Install

npm i xmorse

Weekly Downloads

24

Version

1.0.0

License

MIT

Unpacked Size

34.9 kB

Total Files

40

Last publish

Collaborators

  • atool