Home Reference Source

Function

Static Public Summary
public

decodeMorseCode(morseCode: string, options: Object): string

since 0.0.1 Returns the original message of morse code passed to the function.
public

encodeMorseCode(msg: string, options: Object): string

since 0.0.1 Returns the morse code of message passed to the function.

Static Public

public decodeMorseCode(morseCode: string, options: Object): string since 0.0.1 Returns the original message of morse code passed to the function. source

import {decodeMorseCode} from 'morse-code/src/main.js'

Params:

NameTypeAttributeDescription
morseCode string
  • nullable: false

morse code

options Object
  • optional
  • default: {}
  • nullable: false

optional config

options.long string
  • optional
  • default: "-"
  • nullable: false

the long signal in morse code

options.short string
  • optional
  • default: "."
  • nullable: false

the short signal in morse code

options.delimiter string
  • optional
  • default: "/"
  • nullable: false

the delimiter in morse code

Return:

string (nullable: false)

original code

Example:

ascii
 decodeMorseCode("../..../.-/...-/./.-/.--././-./.-.-.-")
unicode
 decodeMorseCode("--....--.-----/--.....--.----/---..---../.----./.../../-.-./--.....--.---./--....--.-----")
options
 const options = {
     long: "2",
     short: "1",
     delimiter: "0",
 };
 decodeMorseCode("222112221101222210111", options);

public encodeMorseCode(msg: string, options: Object): string since 0.0.1 Returns the morse code of message passed to the function. source

import {encodeMorseCode} from 'morse-code/src/main.js'

Params:

NameTypeAttributeDescription
msg string
  • nullable: false

original message

options Object
  • optional
  • default: {}
  • nullable: false

optional config

options.long string
  • optional
  • default: "-"
  • nullable: false

the long signal in morse code

options.short string
  • optional
  • default: "."
  • nullable: false

the short signal in morse code

options.delimiter string
  • optional
  • default: "/"
  • nullable: false

the delimiter in morse code

Return:

string (nullable: false)

morse code

Example:

ascii
 encodeMorseCode("I have an apple.")
unicode
 encodeMorseCode("もぎゅっと“love”で接近中!")
options
 const options = {
     long: "2",
     short: "1",
     delimiter: "0",
 };
 encodeMorseCode("爱してるばんざーい!", options);