New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

npmmorsecode

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npmmorsecode

npm pack to convert text to morse code and morse code to text

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
0
Created
Source

npmMorsecode

What is this package

npmMorsecode is a JavaScript library that allows you to convert text to Morse code and vice versa. It is useful for anyone who wants to integrate Morse encoding and decoding functionality into their applications.

Installation

To install npmMorsecode, run the following command:

npm install npmMorsecode

Usage Example

Here is an example of how to use npmMorsecode to convert text to Morse code and vice versa:

import { textToMorse } from 'npmmorsecode';
import { morseToText } from 'npmmorsecode';
// Example usage
//init variabile
const text = "Hello World";
const morse= ".... . .-.. .-.. --- .-- --- .-. .-.. -..";
//recall the function
const texttranslated = morseToText(morse);
const morseCode = textToMorse(text);
//print the result
console.log(morseCode);
console.log(texttranslated);

Functions

textToMorse

This function takes a string of text as input and returns the Morse code equivalent.

  • Parameters: text (string) - The text to be converted to Morse code.
  • Returns: (string) - The text converted to Morse code.

morseToText

This function takes a string of Morse code as input and returns the decoded text.

  • Parameters: morse (string) - The Morse code to be converted to text.
  • Returns: (string) - The Morse code converted to text.

Morse Code Formatting

When working with Morse code, it is important to follow these formatting rules to ensure proper encoding and decoding:

  • Only hyphens (-) and dots (.) are allowed.
  • Each letter must be separated by a space.
  • Any other characters will result in an error.

Keywords

morsecode

FAQs

Package last updated on 15 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts