MorseMessage
Direct Subclass:
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';
import MorseCWWave from 'morse-pro-cw-wave';
let morseCWWave = new MorseCWWave();
let morseMessage = new MorseMessage(morseCWWave);
let output;
try {
output = morseMessage.translate("abc");
catch (ex) {
// output will be best attempt at translation
// to understand the detail of where the error is, look at morseMessage.errors or display getErrorString()
}
if (morseMessage.inputWasMorse) {
// do something
}
// get the Morse code waveform
let wave = morseMessage.wave;
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
errors: * |
|
public |
hasError: * |
|
public |
|
|
public |
morse: * |
|
public |
morseCWWave: * |
|
public |
morseTokens: * |
|
public |
rawInput: * |
|
public |
text: * |
|
public |
textTokens: * |
|
public get |
timings: * |
|
public get |
wave: * |
Method Summary
Public Methods | ||
public |
cleanText(): * |
|
public |
getInputErrorString(prefix: String, suffix: String, escapeMap: Map): * |
|
public |
getMorseErrorString(prefix: *, suffix: *): * |
|
public |
getOutputErrorString(prefix: *, suffix: *, escapeMap: {}): * |
|
public |
getTextErrorString(prefix: *, suffix: *, escapeMap: {}): * |
|
public |
loadMorse(input: *): * |
|
public |
loadText(input: *): * |
|
public |
Translate to or from Morse. |
Private Methods | ||
private |
_completeFields(d: *) |
Public Constructors
public constructor() source
Public Members
public errors: * source
public hasError: * source
public inputWasMorse: * source
public morse: * source
public morseCWWave: * source
public morseTokens: * source
public rawInput: * source
public text: * source
public textTokens: * source
public get timings: * source
public get wave: * source
Public Methods
public getMorseErrorString(prefix: *, suffix: *): * source
Params:
Name | Type | Attribute | Description |
prefix | * | ||
suffix | * |
Return:
* |
public getOutputErrorString(prefix: *, suffix: *, escapeMap: {}): * source
Params:
Name | Type | Attribute | Description |
prefix | * | ||
suffix | * | ||
escapeMap | {} |
|
Return:
* |
public getTextErrorString(prefix: *, suffix: *, escapeMap: {}): * source
Params:
Name | Type | Attribute | Description |
prefix | * | ||
suffix | * | ||
escapeMap | {} |
|
Return:
* |
public translate(input: string, isMorse: boolean): * source
Translate to or from Morse.
Return:
* |
Throw:
* |
Error if there was something untranslatable |
Private Methods
private _completeFields(d: *) source
Params:
Name | Type | Attribute | Description |
d | * |