Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

morsify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morsify

Encodes and decodes morse code, creates morse code audio from text.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by180%
Maintainers
1
Weekly downloads
 
Created
Source

morsify

npm-version npm-downloads travis-ci

Morse code encoder and decoder with no dependencies supports Latin, Cyrillic, Greek, Hebrew, Arabic, Persian, Japanese, and Korean characters with audio generation functionality using the Web Audio API.

Installation

npm

$ npm install morsify --save

yarn

$ yarn add morsify

Usage

var morsify = require('morsify');

var encoded = morsify.encode('SOS'); // .../---/... 
var decoded = morsify.decode('.../---/...'); // S O S
var audio = morsify.audio('SOS'), oscillator = audio.oscillator; // OscillatorNode
audio.play(); // play audio
audio.stop(); // stop audio

Or alternatively, you can also use the library directly with including the source file.

<script src="https://rawgit.com/ozdemirburak/morsify/master/index.js"></script>
<script>
    var encoded = morsify.encode('SOS'); // .../---/... 
    var decoded = morsify.decode('.../---/...'); // S O S
    var audio = morsify.audio('SOS'), oscillator = audio.oscillator; // OscillatorNode
    audio.play(); // play audio
    audio.stop(); // stop audio
</script>

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.

What priority option does is, gives direction to the plugin to start to searching for the given character set first.

Set the priority option according to the list below.

  • 1 => ASCII (Default)
  • 2 => Numbers
  • 3 => Punctuation
  • 4 => Latin Extended (Turkish, Polish etc.)
  • 5 => Cyrillic
  • 6 => Greek
  • 7 => Hebrew
  • 8 => Arabic
  • 9 => Persian
  • 10 => Japanese
  • 11 => Korean
var cyrillic = morsify.encode('Ленинград', { priority: 5 }) // .-.././-./../-./--./.-./.-/-..
var greek = morsify.decode('.../.-/--./.-/.--./.--', { priority: 6 }) // Σ Α Γ Α Π Ω
var hebrew = morsify.decode('––– –... ––– –. ––. .. .–.. –––', { dash: '–', dot: '.', space: ' ', priority: 7 }) // ה ב ה נ ג י ל ה
var arabicAudio = morsify.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
  oscillator: {
    type: 'sine', // sine, square, sawtooth, triangle
    frequency: 500,  // value in hertz
    onended: function () { // event that fires when the tone has stopped playing
      console.log('ended');
    },
  }
}), oscillator = arabicAudio.oscillator; // OscillatorNode
arabicAudio.play(); // will start playing morse audio
arabicAudio.stop(); // will stop playing morse audio

Contributing and Known Issues

Contributions are welcome.

Currently, as a major drawback, Chinese characters are missing. Someone with the knowledge of Chinese telegraph code can help to implement it. Also someone who is proficient in Thai can help to include Thai alphabet.

License

The MIT License (MIT). Please see License File for more information.

Keywords

FAQs

Package last updated on 20 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc