Morse Code

Encoding

Encode and decode Morse code with validation support.

Import

Import
import { morse } from 'toolmetry';

API Reference

FunctionParametersReturnsDescription
morseEncodeinput: stringstringEncode text to Morse code
morseDecodeinput: stringstringDecode Morse code to text
morseIsValidinput: stringbooleanCheck if valid Morse code

Examples

Encode/Decode
import { morseEncode, morseDecode } from 'toolmetry';

const encoded = morseEncode('HELLO WORLD');
// ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."

const decoded = morseDecode(encoded);
// "HELLO WORLD"
Validation
import { morseIsValid } from 'toolmetry';

morseIsValid('.... . .-.. .-.. ---'); // true
morseIsValid('hello'); // false

Try It Live