open-index/open-npm huggingface dataset:
npm package: @konsumer/tmdb
Description: This is a simple [TMDB](https://www.themoviedb.org/) library to interact with it, in javascript.
Author: konsumer
Latest version: 0.0.5

This is a simple [TMDB](https://www.themoviedb.org/) library to interact with it, in javascript.

### installation

```sh
npm i @konsumer/tmdb
```

### usage

```js
import TmDB from '@konsumer/tmdb'

const { TMDB_API_KEY } = process.env

if (!TMDB_API_KEY) {
  throw new Error('Please set TMDB_API_KEY')
}

const tmdb = new TmDB(TMDB_API_KEY)

const r = await tmdb.searchMovie("Goonies")
console.log(r)
```

For more examples, see the [unit-test](tmdb.test.js).
npm package: @konsumer/useworker
Description: Simple react hook for offloading work to another thread
Author: David Konsumer
Latest version: 0.0.8

# useWorker

This is a very simple react-hook for offloading work into another webworker-thread. It simplifies using web-workers, and doesn't require seperate JS files to define your worker.

Web workers have a slightly different API than plain browser stuff, so make sure to [read about them](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers).

Main consideration is that you can only pass values that are ok (JSONable, no functions, errors, etc, but `File` and `Blob` and more is ok) and you use `postMessage` in your `onWork` function to fire the `onFinish`. You can post multiple times, and it will each fire `onFinish` on each.

Use this whenever you can benefit from putting work in another thread, on the web. Inside the `onWork` thread, you can do `fetch`, web-sockets, `OffscreenCanvas`, and lots more. Think of it as "`useEffect` on another thread."

## installation

```
npm i @konsumer/useworker
```

## usage

You can see an [example hook](./example/src/useResizeImage.js) where I resize uploaded images in a worker.

Basic idea is like this:

```jsx
import useWorker from '@konsumer/useworker'

// worker-side, called as worker. It can be a string or a function.
// Must be self-contained.
// It gets it's input from event.data, and outputs with postMessage
function onWork({data}) {
  // do whatever with data, in worker
  console.log(`useworker is ${data || 'amazing'}!`)
  postMessage('I finished.')
}

// host-side, called when worker does a postMessage
function onFinish(response) {
  // response is whatever onWork() called with postMessage()
  console.log(response)
}

// host-side, called when worker has an error
function onError(e) {
  console.error(e.message)
}

function MyThing() {
  // all params are optional
  const doStuff = useWorker ({ onWork, onFinish, onError })

  // call doStuff when you want to do work, it will send input arg as event.data
  doStuff('cool')

  return (
    <div>
      Check the console
    </div>
  )
}
```
npm package: @konsumer/ytdownload
Description: Simple youtube video downloader CLI & library
Author: David Konsumer
Latest version: 0.0.6

This is a simple info/download utility/library for youtube videos.

## Usage

### CLI

```
npx -y @konsumer/ytdownload <YOUTUBE_ID> [OUTFILE] [SIZE]
```

- `YOUTUBE_ID` - required - Your youtube-id, like `dQw4w9WgXcQ`
- `OUTFILE` - optional - the filename you want to output
- `SIZE` - optional - one of these - `hd1080|hd720|large|medium|small|tiny`


### Code

```js
import getYoutubeInfo from '@konsumer/ytdownload'

const info = await getYoutubeInfo('dQw4w9WgXcQ')

```

Youtube seperates the audio/video streams, so you will need to figure out how to merge them. See [my CLI](dl.mjs) for an example.