1.3.0 • Published 1 year ago
morse-to-chain v1.3.0
Table of Contents
Features
- Do text to morse code conversions
- Supports letters numbers and symbols
- Text type responses are in upper case
- Text entries can be upper or lower case
- If the translation of a character to Morse code is not found, it will be returned as an UNDEFINED response.
- You can add the translation of a code if it were missing
Installing
Package manager
Using npm:
$ npm install morse-to-chain
Using bower:
$ bower install morse-to-chain
Using yarn:
$ yarn add morse-to-chain
Using pnpm:
$ pnpm add morse-to-chain
Once the package is installed, you can import the library using require
and destructure the list data, approach:
const [convertToMorse, convertToText, addElementCode] = require("morse-to-chain");
you can also use split import:
const morseCodeMethods = require("morse-to-chain");
const convertToMorse = morseCodeMethods[0];
const convertToText = morseCodeMethods[1];
const addElementCode = morseCodeMethods[2];
;
Example
Note CommonJS usage Note using CommonJS, you will be using
require()
, use the following approach:
const [convertToMorse, convertToText] = require("morse-to-chain");
// performs the conversion of a text string to morse code
convertToMorse('HELLO WORLD');
//Output ('.... . .-.. .-.. --- / .-- --- .-. .-.. -..');
// performs the conversion of a morse code to a text string
convertToText('-. --- -.. . .--- ...')
//Output (NODEJS);
additional-resources
MorseCode includes a method so you can add morse codes that are not registered, use the following approach.
const [convertToMorse, convertToText] = require("morse-to-chain");
// performs the conversion of a text string to morse code
convertToMorse('HELLO ❄ ❄');
//Output (the value ( ❄ ) does not have a morse translation if you want you can add it to the list);
then
const [convertToMorse, convertToText, addElementCode] = require("morse-to-chain");
// we add the element together with its morse code
// first parameter: element
// second parameter: morse code
addElementCode('❄', 'codeMorse');
convertToMorse('HELLO ❄ ❄');
//Output (.... . .-.. .-.. --- / codeMorse / codeMorse)
Author
VLADIMIR MAIDANA ACARAPI