# cw

> A comprehensive Morse Code (CW) library

Latest version **0.4.0** (published 2025-03-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install cw
pnpm add cw
yarn add cw
bun add cw
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2025-03-06 |
| First published | 2013-08-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 26.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Yuval Adam |
| Maintainers | yuvadm |
| Keywords | morse, code, cw, continuous, wave |

## Links

- npm: https://www.npmjs.com/package/cw
- Repository: https://github.com/mastercw/cw.js
- Homepage: https://www.mastercw.com/cw.js/
- Issues: https://github.com/mastercw/cw.js/issues
- npm.io page: https://npm.io/package/cw

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.4.0 (latest) — 2025-03-06
- 0.3.0 — 2025-03-04
- 0.2.1 — 2020-06-29
- 0.2.0 — 2020-06-29
- 0.1.2 — 2020-06-09
- 0.1.1 — 2020-06-09
- 0.1.0 — 2020-06-09
- 0.0.1 — 2013-08-07

## README

# CW.js

[![Node.js CI](https://github.com/mastercw/cw.js/workflows/Node.js%20CI/badge.svg)](https://github.com/mastercw/cw.js/actions)
[![NPM](https://img.shields.io/npm/v/cw)](https://www.npmjs.com/package/cw)

A comprehensive Morse Code (CW) library, brought to you by [Master CW](https://www.mastercw.com/).

## Usage

### Node

Install the package via `npm` or `yarn`:

```bash
$ npm install cw
```

#### ES Modules

```javascript
import cw from "cw";
console.log(cw.codes["C"]); // "-.-."
cw.play("hello world");
```

#### CommonJS

```javascript
const cw = require("cw");
console.log(cw.codes["C"]); // "-.-."
```

### Browser

You can either build the browser bundle yourself with:

```bash
$ npm install
$ npm run build
```

Which will create `dist/cw.js` and `dist/cw.min.js`. Or you can use it from a CDN:

#### jsDelivr CDN (Recommended)

```html
<script src="https://cdn.jsdelivr.net/npm/cw@0.4.0/dist/cw.min.js"></script>
```

or just use `latest`:

```html
<script src="https://cdn.jsdelivr.net/npm/cw@latest/dist/cw.min.js"></script>
```

#### Legacy CDN

The legacy CDN is still available for backwards compatability but will be deprecated soon:

```html
<script src="https://cwjs.mastercw.com/cw.min.js"></script>
```

Once the script is loaded you can call the `cw.play()` function:

```html
<script>
  cw.play("hello world");
</script>
```

Options can be passed to customize the played sequence:

```js
cw.play("abcd", {
  tone: 800, // tone frequency in Hz
  wpm: 20, // character speed in words per minute (WPM)
  fwpm: 10, // farnsworth speed in words per minute (WPM)
});
```

In cases of multiple plays, it is recommended to create a global `audioContext` object:

```js
// Initialize audio context once
let actx = cw.initAudioContext({ tone: 600 }); // tone is passed here

// Reuse the audio context for multiple plays
cw.play("abcd", { actx, wpm: 10 });
cw.play("efgh", { actx, wpm: 20 });
cw.play("ijkl", { actx, wpm: 30 });
```

For more examples see the [examples/](examples/) directory.

### Testing

```bash
$ npm test
```

## License

ISC

---
_Source: https://npm.io/package/cw · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
