morse-encoder-decoder
v1.1.3
Published
this is a simple string encoder decoder package
Downloads
5
Readme
What is this?
Can encode and decode string to special charecters and vice-versa
For more details about morse pattern morse
Table of Content
Installation
npm i morse-encoder-decoder
Import Syntax
using CommonJS imports with require()
use the following approach:
const {} = require("morse-encoder-decoder")
Example
Performing synchronous encoding
const {morseSyncEncoding} = require("morse-encoder-decoder")
let result = morseSyncEncoding("Hello world")
output
....*/./.-../.-../---/ /.--/---/.-./.-../-../
Performing synchronous decoding
const {morseSyncDecoding} = require("morse-encoder-decoder")
let decodeData = morseSyncDecoding('....*/./.-../.-../---/ /.--/---/.-./.-../-../')
output
Hello world
Using promise
Performing Asynchronous encoding
const {morseAsyncEncoding} = require("morse-encoder-decoder")
morseAsyncEncoding("Hello world").then(result => {
console.log(result);
}).catch(error => {
console.log(error);
})
output
....*/./.-../.-../---/ /.--/---/.-./.-../-../
Performing Asynchronous decoding
const {morseAsyncDecoding} = require("morse-encoder-decoder")
morseAsyncDecoding("--.*/---/---/-../ /-.*/../--./..../-/").then(result => {
console.log(result);
}).catch(error => {
console.log(error);
})
output
Hello world
Using async/await
Performing Asynchronous encoding
async function encoder() {
let result = await morseAsyncDecoding("Hello world")
console.log(result);
}
output
....*/./.-../.-../---/ /.--/---/.-./.-../-../
Performing Asynchronous decoding
async function decoder() {
let result = await morseAsyncDecoding("....*/./.-../.-../---/ /.--/---/.-./.-../-../")
console.log(result);
}
output
Hello world