1.1.3 • Published 3 years ago

morse-encoder-decoder v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

What is this?

Can encode and decode string to special charecters and vice-versa

For more details about morse pattern morse

Table of Content

  1. Installation
  2. Import Syntax
  3. Example

    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
1.1.1

3 years ago

1.1.0

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.0

3 years ago