npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ozdemirburak/morse-code-translator

v6.0.0

Published

Morse code translator helps you convert text to Morse code and vice versa, with the option to play Morse code audio.

Readme

Morse Code Translator

npm-version npm-downloads

Morse code encoder and Morse decoder with no dependencies. It supports Latin, Cyrillic, Greek, Hebrew, Arabic, Persian, Japanese, Korean, and Thai, with audio-generation functionality using the Web Audio API.

Installation

npm

$ npm install @ozdemirburak/morse-code-translator --save

Usage

import morse from '@ozdemirburak/morse-code-translator';

const encoded = morse.encode('SOS'); // ... --- ...
const decoded = morse.decode('... --- ...'); // SOS
const characters = morse.characters(); // {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}

const audio = morse.audio('SOS');

// Playback control
await audio.play();           // play audio (returns Promise)
audio.pause();                // pause audio
await audio.play();           // resume from paused position
await audio.seek(1.5);        // seek to 1.5 seconds
audio.stop();                 // stop audio and reset to beginning
audio.dispose();              // cleanup and dispose audio resources

// Playback state and info
audio.getState();             // 'ready', 'playing', 'paused', or 'stopped'
audio.getCurrentTime();       // current playback position in seconds
audio.getTotalTime();         // total duration in seconds

// Export audio
await audio.exportWave();     // download audio wave file (promise)
const url = await audio.getWaveUrl();  // get audio wave url (promise)
const blob = await audio.getWaveBlob(); // get audio wave blob (promise)

Options and localization

You can customize the dash, dot, or space characters and specify the alphabet with the priority option for an accurate encoding and decoding.

The priority option gives direction to the plugin to start searching for the given character set first.

Set the priority option according to the list below.

  • 1 => ASCII (Default)
  • 2 => Numbers
  • 3 => Punctuation
  • 4 => Latin Extended (Turkish, Polish etc.)
  • 5 => Cyrillic
  • 6 => Greek
  • 7 => Hebrew
  • 8 => Arabic
  • 9 => Persian
  • 10 => Japanese
  • 11 => Korean
  • 12 => Thai
const cyrillic = morse.encode('Ленинград', { priority: 5 }); // .-.. . -. .. -. --. .-. .- -..
const greek = morse.decode('... .- --. .- .--. .--', { priority: 6 }); // ΣΑΓΑΠΩ
const hebrew = morse.decode('.. ––– . –––', { dash: '–', dot: '.', priority: 7 }); // יהוה
const japanese = morse.encode('NEWS', { priority: 10, dash: '-', dot: '・', separator: ' ' }); // -・ ・ ・-- ・・・
const characters = morse.characters({ dash: '–', dot: '•' }); // {'1': {'A': '•–', ...}, ..., '11': {'ㄱ': '•–••', ...}}
const arabicAudio = morse.audio('البراق', { // generates the Morse .- .-.. -... .-. .- --.- then generates the audio from it
  wpm: 18, // sets the wpm based on the Paris method, note that setting this will override and set the unit and fwUnits accordingly
  unit: 0.1, // period of one unit, in seconds, 1.2 / c where c is speed of transmission, in words per minute
  fwUnit: 0.1, // period of one Farnsworth unit to control intercharacter and interword gaps
  volume: 100, // the volume in percent (0-100)
  oscillator: {
    type: 'sine', // sine, square, sawtooth, triangle
    frequency: 500  // value in hertz
  },
  events: {
    onready: () => console.log('Audio is ready'),
    onstarted: () => console.log('Playback started'),
    onpaused: () => console.log('Playback paused'),
    onstopped: () => console.log('Playback stopped'),
    onended: () => console.log('Playback completed naturally'),
    onseeked: (time) => console.log('Seeked to:', time)
  }
});

// Access to Web Audio API nodes (for advanced users)
const oscillator = arabicAudio.oscillator; // OscillatorNode
const context = arabicAudio.context; // AudioContext
const gainNode = arabicAudio.gainNode; // GainNode

// Playback control
await arabicAudio.play(); // will start playing Morse audio
arabicAudio.pause();      // will pause Morse audio
await arabicAudio.play(); // will resume from where it was paused
arabicAudio.stop();       // will stop and reset to beginning

Contributions

morse-code-translator has been developed with extensive feedback and contributions from numerous developers.

Special thanks to Chris Jones, who added many great features.

License & Attribution

MIT licensed, use it however you want. But if this library saved you time, link back to the project homepage. It is how open-source maintainers get credit for their work.

<a href="https://morsecodetranslator.com">Morse Code Translator</a>

Takes 30 seconds. Appreciated, not required.