Giter VIP home page Giter VIP logo

morsejs's Introduction

morsejs

npm version Build Status Inline docs

A morse code translation library written in JavaScript

Working implementation of morsejs

Translation

morsejs:translate will translate a given String to an Array of Numbers found in the signal enumeration (by default: -1, 0, and 1).

The return structure is formated so that it is similar to the transmission format of a morse message. This means that it includes the spacing between symbol signals, the symbols themselves, and words. See transmission of morse code on Wikipedia for a better explanation.

By default, this library transmits -1 for any padding between signals, symbols, or words. Similarly, it sends 0 for a short signal and 1 for a long signal. Really, if we were to follow the transmission format correctly, we should send 0 for padding and 1 for short or long since it would be more aking to on/off.

The rational for this is that we can compress the data from having to have 3 1's for a long to just one number but since we don't distinguish between the different paddings, we are wasting space anyway. That's why this may or may not change or maybe become a compression setting.

Consider the transmission of "SOS":

         1         2         3
123456789012345678901234567890
-_-_-___---_---_---___-_-_-

morsejs would actually return:

[ 0, -1, 0, -1, 0, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 0, -1, 0, -1, 0 ]

Installation

Binary

npm install -g morsejs

Dependency

npm install --save morsejs

Usage

CLI

morsejs hello world

JS

If you just want to plainly translate a message, you can just use translate

var message = morsejs.translate("hello world");

Plugins

There are plugins that can use the output from morsejs to render it in different ways.

morsejs's People

Contributors

zero298 avatar

Stargazers

Roman avatar Jannis R avatar

Watchers

 avatar

morsejs's Issues

Update README to show how to use encoding

Commit 9dfb3cf added the ability to use different encoding types while translating.

For now the expected encoding options are:

  • Padding - The old default style where everything is verbose and enumerated
    • Implementation
    • Documentation
  • DotDash - A more graphical representation that returns a string showing on/off signal
    • Implementation
    • Documentation
  • RLE - Run-length encoded style where on/off signals are compressed
    • Implementation
    • Documentation

Translation text input does not accept spaces

The translation text input does not allow for spaces which the library has support for. This is easy to fix by modifying the pattern attribute on the translationText <input> in the index.html file to allow for spaces in addition to alphanumeric. This is from commit e391315018c26c245acced9c64b7a2c82996e23e

Morse code render can go off screen

There is no limit to where dots and dashes can be rendered within the <svg>. They should wrap to a new line whenever they are about to render off screen. This is from commit e391315018c26c245acced9c64b7a2c82996e23e

Should the SVG and WebAudio be a separate module?

I'm not sure if this is the correct pattern to approach this, but since the main morsejs plugin can run by itself, should the SVG and WebAudio pieces be separated into a different module that can be included and used?

I'm drawing inspiration for this from how less.js moved the cleaning functionality out from the main module and instead has the user include it separately as a plugin with less-plugin-clean-css.

This is an incredible amount of overkill effort considering how small this project is, but the main goal is to play with the different API available for node modules and tools.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.