Skip to content

Commit

Permalink
v3.0, renamed package and added audio export feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
ozdemirburak committed Oct 9, 2020
1 parent 0ea056d commit 0d750ba
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 931 deletions.
15 changes: 9 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.{js,json,ts,tsx}]
indent_style = space
indent_size = 2

[*.{md,markdown}]
trim_trailing_whitespace = false
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage/
node_modules/
coverage
node_modules
npm-debug.log
package-lock.json
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"debug": false,
"esversion": 6
"esversion": 8
}
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
coverage/
npm-debug.log
coverage
package-lock.json
.idea
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

language: node_js

node_js:
- node
- 6
- lts/*

after_script:
- npm run test-cov
Expand Down
62 changes: 20 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,40 @@
# [Morse Code Translator](https://morsedecoder.com) with Audio - Morsify
# [Morse Code Translator](https://morsedecoder.com) with Audio - Morse Decoder

[![npm-version]][npm] [![npm-downloads]][npm] [![travis-ci]][travis]
[![npm-version]][npm] [![npm-downloads]][npm]

Morsify is a Morse code encoder and decoder with no dependencies. Currently, it supports Latin, Cyrillic, Greek, Hebrew, Arabic,
Morse code encoder and decoder with no dependencies. It supports Latin, Cyrillic, Greek, Hebrew, Arabic,
Persian, Japanese, Korean, and Thai, with audio-generation functionality using the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API).

## Installation

### npm

```bash
$ npm install morsify --save
$ npm install morse-decoder --save
```

### yarn

```bash
$ yarn add morsify
$ yarn add morse-decoder
```

## Usage

```js
const morsify = require('morsify');
const encoded = morsify.encode('SOS'); // ... --- ...
const decoded = morsify.decode('... --- ...'); // SOS
const characters = morsify.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}
const audio = morsify.audio('SOS');
const morse = require('morse-decoder');
const encoded = morse.encode('SOS'); // ... --- ...
const decoded = morse.decode('... --- ...'); // SOS
const characters = morse.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}
const audio = morse.audio('SOS');
audio.play(); // play audio
audio.stop(); // stop audio
audio.exportWave(); // download audio wave file (promise)
const url = await audio.getWaveUrl(); // get audio wave url (promise)
const blob = await audio.getWaveBlob(); // get audio wave blob (promise)
```

Alternatively, you can use the library directly with including the source file.

```html
<script src="https://rawgit.com/ozdemirburak/morsify/master/dist/morsify.min.js"></script>
<script>
var encoded = morsify.encode('SOS'); // ... --- ...
var decoded = morsify.decode('... --- ...'); // SOS
var characters = morsify.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}
var audio = morsify.audio('SOS');
var oscillator = audio.oscillator; // OscillatorNode
var context = audio.context; // AudioContext
var gainNode = audio.gainNode; // GainNode
audio.play(); // play audio
audio.stop(); // stop audio
audio.exportWave(); // download audio wave file (promise)
var url = await audio.getWaveUrl(); // get audio wave url (promise)
var blob = await audio.getWaveBlob(); // get audio wave blob (promise)
</script>
```

## Options and Localization
### Options and localization

You can customize the dash, dot, or space characters and specify the alphabet with the priority option for
an accurate encoding and decoding.
Expand All @@ -77,12 +57,12 @@ Set the priority option according to the list below.
- 12 => Thai

```js
const cyrillic = morsify.encode('Ленинград', { priority: 5 }); // .-.. . -. .. -. --. .-. .- -..
const greek = morsify.decode('... .- --. .- .--. .--', { priority: 6 }); // ΣΑΓΑΠΩ
const hebrew = morsify.decode('.. ––– . –––', { dash: '', dot: '.', priority: 7 }); // יהוה
const japanese = morsify.encode('NEWS', { priority: 10, dash: '', dot: '', separator: ' ' }); // -・ ・ ・-- ・・・
const characters = morsify.characters({ dash: '', dot: '' }); // {'1': {'A': '•–', ...}, ..., '11': {'ㄱ': '•–••', ...}}
const arabicAudio = morsify.audio('البراق', { // generates the Morse .- .-.. -... .-. .- --.- then generates the audio from it
const cyrillic = morse.encode('Ленинград', { priority: 5 }); // .-.. . -. .. -. --. .-. .- -..
const greek = morse.decode('... .- --. .- .--. .--', { priority: 6 }); // ΣΑΓΑΠΩ
const hebrew = morse.decode('.. ––– . –––', { dash: '', dot: '.', priority: 7 }); // יהוה
const japanese = morse.encode('NEWS', { priority: 10, dash: '', dot: '', separator: ' ' }); // -・ ・ ・-- ・・・
const characters = morse.characters({ dash: '', dot: '' }); // {'1': {'A': '•–', ...}, ..., '11': {'ㄱ': '•–••', ...}}
const arabicAudio = morse.audio('البراق', { // generates the Morse .- .-.. -... .-. .- --.- then generates the audio from it
unit: 0.1, // period of one unit, in seconds, 1.2 / c where c is speed of transmission, in words per minute
fwUnit: 0.1, // period of one Farnsworth unit to control intercharacter and interword gaps
oscillator: {
Expand Down Expand Up @@ -117,9 +97,7 @@ $ gulp
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.

[npm-version]: https://img.shields.io/npm/v/morsify.svg?style=flat-square
[npm-downloads]: https://img.shields.io/npm/dm/morsify.svg?style=flat-square
[travis-ci]: https://img.shields.io/travis/ozdemirburak/morsify/master.svg?style=flat-square
[npm-version]: https://img.shields.io/npm/v/morse-decoder.svg?style=flat-square
[npm-downloads]: https://img.shields.io/npm/dm/morse-decoder.svg?style=flat-square

[npm]: https://www.npmjs.com/package/morsify
[travis]: https://travis-ci.org/ozdemirburak/morsify
[npm]: https://www.npmjs.com/package/morse-decoder
1 change: 1 addition & 0 deletions dist/morse-decoder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0d750ba

Please sign in to comment.