morse
A simple Morse code library for nodeinstall
For use as a CLI:npm install -g morse
For use as a library:npm install morse
example usage as a CLI
```` morse -hmorse hello > hello.txt
morse -d "
cat hello.txt
"
````example usage as a library
````javascript var morse = require('morse');var encoded = morse.encode('Hello, world.'); // .... . .-.. .-.. --- --..-- ....... .-- --- .-. .-.. -.. .-.-.-
morse.decode(encoded); // HELLO, WORLD. ````
````javascript var encoded = morse.encode( 'hello', 'world' ); // '.... . .-.. .-.. ---', '.-- --- .-. .-.. -..'
morse.decode(encoded); // 'HELLO', 'WORLD' ````
methods
morse.encode(str)
Encodes and returns a given stringmorse.decode(str, dichotomic)
Decodes and returns a string or arraydichotomic
defaults to false. If passed true, it will use a tree-based approach to decode the string or array. If false, a basic iteration of the map is used.The dichotomic approach looks like this:
The implementation does not include spaces right now, so it fails its test. However, it is otherwise accurate.
````javascript morse.decode( morse.encode('Hello, world.'), true ); // HELLO,5WORLD. ````
attributes
morse.map
An object containingletter: morse
translations contained in map.js
morse.tree
A tree-modeled object contained intree.js