2.0.0 • Published 2 years ago

morse-tr v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

morse-tr

Fast morse code translation module.

npm i morse-tr

const morseTr = require('morse-tr');

Morse Code formatting

  • Parts of a letter aren't separated.
  • Letters of a word are separated by a single space.
  • Word are separated by a slash.

Documentation

encrypt(text)

  • text - string, message to encrypt.

If a letter is used in the string that isn't present in the notation a hash # will be inserted in its place.

morseTr.encrypt('hello');         // '.... . .-.. .-.. ---'
morseTr.encrypt('aą bć');         // '.- # / -... #'
morseTr.encrypt('.- -.. <>?');    // null

decrypt(text)

  • text - string, morse code to decrypt.

If a morse letter is used in the string that isn't present in the notation a # will be inserted in its place.

If the input is not matched by the validation regex function returns null.

morseTr.decrypt('.... . .-.. .-.. ---');          // 'hello'
morse.decrypt('.- .-.-...- / -... --.-.-..-');    // 'a# b#'

isValidMorse(text)

  • text - string, morse code to check.

Checks if a string is valid morse code.

morseTr.isValidMorse('-.. . .-..');    // true
morseTr.isValidMorse('-.. . <>?');     // false

Notation

Notation properties:

  • .letters
  • .numbers
  • .symbols
  • .characters
  • .regex
  • .unknownChar

Each character is an object with text and morse properties.

morseTr.notation.letters[0];
// { text: 'a', morse: '.-' }
2.0.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago