open-index/open-npm huggingface dataset:
npm package: @jamen/ws-extras
Description: Functions for using WebSockets on Node.js.
Author: Jamen Marz
Latest version: 0.1.0

# @jamen/ws-extras

Functions for using WebSockets on Node.js.

This package is inpsired after [`micro`](https://github.com/zeit/micro), except made for WebSockets instead of HTTP. Its designed for use with [`ws`](https://github.com/websockets/ws).

## Usage

### `loop(conn, recv)`

A loop for receiving messages from the connection through `recv`. Once the connection closes the loop completes.

```js
const WebSocket = require('ws')
const { loop } = require('@jamen/ws')

const server = new WebSocket.Server({ host, port })

server.on('connection', conn => loop(conn, recv))

async function recv (conn) {
    // Receive messagess
}
```

To receive messages from `conn` see the functions `buffer`, `text`, and `json`.

### `buffer(conn, options)`

### `text(conn, options)`

### `json(conn, options)`

Receive the next buffer, text, or JSON message.

The `options` is an object that can contain

- `limit`: A [byte amount](https://github.com/visionmedia/bytes.js#readme) of how large the message can be. Defaults to `'1mb'`.
- `timeout`: A [duration](https://github.com/zeit/ms) to stop waiting for the message. When `false` it never stops. Defaults to `'1m'`.
- `encoding`: The preferred encoding. Defaults to `'utf8'.

The function returns a promise resolving the result. The promise can reject with an error if the limit is reached, the timeout is reached, or an error from `ws` emerges.

```js
const { buffer, text, json } = require('@jamen/ws')

async function recv (conn) {
    let message
    // Next message as a buffer
    message = await buffer(conn)
    // As text
    message = await text(conn, { limit: '5mb', timeout: '30s' })
    // As JSON
    message = await json(conn, { limit: 2097152, timeout: 60000 })
    // Without timeout
    message = await json(conn, { timeout: false })
}
```

### `jsonEvent(conn, options)`

Similar to `json` except only `{ event, data }` is allowed.

The `options` are the same.

The returned promise can be rejected if the message is not a `{ event, data }` structure.

```js
const { jsonEvent } = require('@jamen/ws')

async function recv (conn) {
    const { name, data } = await jsonEvent(conn)

    // ...
}
```
npm package: @jamerly/chatbox
Description: A customizable chatbox component for web applications.
Latest version: 0.1.10

# ChatBox

This is a simple chat application built with React, TypeScript, and Vite.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

You need to have [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/) (or [yarn](https://yarnpkg.com/)) installed on your machine.

### Installation

1.  Clone the repo
    ```sh
    git clone https://github.com/your_username/chatbox.git
    ```
2.  Install NPM packages
    ```sh
    npm install
    ```

## Available Scripts

In the project directory, you can run:

### `npm run dev`

Runs the app in the development mode.<br />
Open [http://localhost:5173](http://localhost:5173) to view it in the browser. (The port may vary)

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `npm run build`

Builds the app for production to the `dist` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

### `npm run lint`

Lints the project files using ESLint.

### `npm run preview`

Serves the production build locally to preview the app.

## Built With

*   [React](https://reactjs.org/) - The web framework used
*   [Vite](https://vitejs.dev/) - Build tool
*   [TypeScript](https://www.typescriptlang.org/) - Language
npm package: @jamerly/chatboxtest
Description: A customizable chatbox component for web applications.
Latest version: 0.1.9

# ChatBox

This is a simple chat application built with React, TypeScript, and Vite.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

You need to have [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/) (or [yarn](https://yarnpkg.com/)) installed on your machine.

### Installation

1.  Clone the repo
    ```sh
    git clone https://github.com/your_username/chatbox.git
    ```
2.  Install NPM packages
    ```sh
    npm install
    ```

## Available Scripts

In the project directory, you can run:

### `npm run dev`

Runs the app in the development mode.<br />
Open [http://localhost:5173](http://localhost:5173) to view it in the browser. (The port may vary)

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `npm run build`

Builds the app for production to the `dist` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

### `npm run lint`

Lints the project files using ESLint.

### `npm run preview`

Serves the production build locally to preview the app.

## Built With

*   [React](https://reactjs.org/) - The web framework used
*   [Vite](https://vitejs.dev/) - Build tool
*   [TypeScript](https://www.typescriptlang.org/) - Language