https://github.com/hustcc/xmorse
:sun_with_face: ~1.5Kb morse code library for all. 一个支持 Unicode 中文摩斯密码编码的 Javascript 库。
https://github.com/hustcc/xmorse
chinese decoding encoding javascript morse morse-code unicode
Last synced: 17 days ago
JSON representation
:sun_with_face: ~1.5Kb morse code library for all. 一个支持 Unicode 中文摩斯密码编码的 Javascript 库。
- Host: GitHub
- URL: https://github.com/hustcc/xmorse
- Owner: hustcc
- License: mit
- Created: 2017-01-16T07:27:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-05T06:45:27.000Z (almost 3 years ago)
- Last Synced: 2025-03-29T07:05:58.077Z (24 days ago)
- Topics: chinese, decoding, encoding, javascript, morse, morse-code, unicode
- Language: TypeScript
- Homepage: https://atool.vip/morse
- Size: 26.4 KB
- Stars: 323
- Watchers: 17
- Forks: 63
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Xmorse
> **Xmorse** is a pure javascript(~1.5kb) library for encoding / decoding morse code messages, **unicode supported**.
[中文说明文档](README_ZH.md) | [Online DEMO 地址](https://atool.vip/morse)
[](https://github.com/hustcc/xmorse/actions)
[](https://coveralls.io/github/hustcc/xmorse?branch=master)
[](https://www.npmjs.com/package/xmorse)
[](https://www.npmjs.com/package/xmorse)
[](https://www.npmjs.com/package/xmorse)# 1. Install
> **npm install xmorse**
Or download `dist/xmorse.min.js` source file。
# 2. Import It
- `Script` tag.
```html
```
- `ES6` style.
```ts
import { decode, encode } from 'xmorse';
```# 3. Usage & API
There is only 2 API named `encode`, `decode`. For `encode(msg, [option])`, example:
```ts
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:
```ts
import { decode, encode } from 'xmorse';
decode('../.-../---/...-/./-.--/---/..-/-/---/---/--...-....-...-/-..---..-.-----/---..-...--...-/-..----.--.....');// option
const option = {
space: ' ',
long: '-',
short: '*'
};
decode('*-** --- ***- *', option);
```# 4. Test
```bash
$npm install$npm test
```# 5. LICENSE
MIT@[hustcc](https://github.com/hustcc)