# fetch-pitch

> Sonify your fetch API requests

Latest version **1.0.0** (published 2022-04-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install fetch-pitch
pnpm add fetch-pitch
yarn add fetch-pitch
bun add fetch-pitch
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-04-02 |
| First published | 2022-04-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jack Carrick |
| Maintainers | jaqarrick |
| Keywords | tone, tonejs, web audio, sonification, fetch |

## Links

- npm: https://www.npmjs.com/package/fetch-pitch
- npm.io page: https://npm.io/package/fetch-pitch

## Dependencies (2)

- [tone](https://npm.io/package/tone.md) ^14.7.77
- [user](https://npm.io/package/user.md) ^0.0.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-04-02

## README

# Fetch Pitch
Fetch Pitch allows you to easily sonify your applications that use the fetch API. Each network request binds to a ToneJS instrument with a specified callback

## Usage

### `pitch(instrument, callback, resource, opts)`
### `new FetchPitch(instrument, callback)`
- `instrument`: any ToneJS instrument
- `callback`: what you want the instrument to do. This must be a function where the instrument argument is called by the method` (see example below)
- `resource`: fetch resource (url, or Request) like `https://example.com`
- `opts`: options you'd normally pass to a fetch request.


Standalone with `pitch` function
```
import { pitch } from 'fetch-pitch'
import * as Tone from 'tone'

const synth = new Tone.Synth().toDestination()
const callback = instrument => instrument.triggerAttachRelease("C4", "4n")

pitch(synth, callback, "http://localhost:1312/my-api", {
    method: 'GET
}).then(res => {
    console.log(res.statusCode)
})

```

or use with existing fetch requests using the `FetchPitch.fetch` method

```
// Before
const someAsyncNetworkCall = async () => {

    const response = await fetch("http://localhost:1312/my-api", {
        method: 'GET
    })

}
import { FetchPitch } from 'fetch-pitch'
// After (using same synth and callback as above)
const myPitch = new FetchPitch(synth, callback);

const someAsyncNetworkCall = async () => {

    const response = await myPitch.fetch("http://localhost:1312/my-api", {
        method: 'GET
    })

}


```

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