Home Reference Source
import MorseMessage from 'morse-pro/src/morse-pro-message.js'
public class | source

MorseMessage

Direct Subclass:

MorseCW

Indirect Subclass:

MorseCWWave

Class for conveniently translating to and from Morse code. Deals with error handling. Works out if the input is Morse code or not.

Example:

import MorseMessage from 'morse-pro-message';
var morseMessage = new MorseMessage();
var input;
var output;
try {
    output = morseMessage.translate("abc");
catch (ex) {
    // input will have errors surrounded by paired '#' signs
    // output will be best attempt at translation, with untranslatables replaced with '#'
    morseMessage.clearError();  // remove all the '#'
}
if (morseMessage.inputWasMorse) {
    // do something
}

Constructor Summary

Public Constructor
public

constructor(prosigns: boolean)

Member Summary

Public Members
public
public
public
public
public
public
public

Method Summary

Public Methods
public

Clear all the errors from the morse and message.

public

translate(input: string, isMorse: boolean): *

Public Constructors

public constructor(prosigns: boolean) source

Params:

NameTypeAttributeDescription
prosigns boolean
  • optional
  • default: true

whether or not to include prosigns in the translations

Public Members

public hasError: * source

public input: string source

public inputWasMorse: * source

public message: string source

public morse: string source

public output: string source

public useProsigns: * source

Public Methods

public clearError() source

Clear all the errors from the morse and message. Useful if you want to play the sound even though it didn't translate.

public translate(input: string, isMorse: boolean): * source

Params:

NameTypeAttributeDescription
input string

alphanumeric text or morse code to translate

isMorse boolean

whether the input is Morse code or not (if not set then the looksLikeMorse method will be used)

Return:

*