open-index/open-npm huggingface dataset:
npm package: @hazae41/signals
Description: Utilities to deal with AbortSignal
Author: hazae41
Latest version: 1.1.0

# Signals

Utilities to deal with AbortSignal

```bash
npm i @hazae41/signals
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/signals)

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Merge signals
- Optional signals
- Promisify signals

## Usage

### Never

```tsx
Signals.never()
```

This can be useful when you want to accept an optional AbortSignal without branching or doing weird merging

```tsx
function run(signal: AbortSignal);

// GOOD EXAMPLE
function f(signal = Signals.never()) {
  run(signal)
}

// BAD EXAMPLE
function g(signal?: AbortSignal) {
  if (signal == null)
    run(new AbortController().signal)
  else
    run(signal)
}
```

### Merge

```tsx
Signals.merge(a, b?)
```

This can be useful when you have signals with different scopes

```tsx
const global = AbortSignal.timeout(10 * 1000)

async function f(parent?: AbortSignal) {
  const signal = Signals.merge(global, parent)

  await fetch("...", { signal })
}
```

### resolveOnAbort / rejectOnAbort

```tsx
Signals.rejectOnAbort(signal)
```

This is very useful when you want to race a signal with a promise

```tsx
async function run();

async function runWithTimeout(delay: number) {
  const signal = AbortSignal.timeout(delay)
  using timeout = Signals.rejectOnAbort(signal)

  await Promise.race([run(), timeout.get()])
}
```

This converts any event-based signal into a disposable promise

You can also use `resolveOnAbort` to avoid storing unhandled promises

```tsx
async function run();

const global = AbortSignal.timeout(10 * 1000)
using timeout = Signals.resolveOnAbort(global)

async function runWithTimeout() {
  const rejectOnAbort = timeout.get().then(() => { throw new Error("Aborted") })

  await Promise.race([run(), rejectOnAbort])
}
```
npm package: @hazae41/smux
Description: Zero-copy SMUX protocol for the web
Author: hazae41
Latest version: 1.1.5

# SMUX

Zero-copy SMUX protocol for the web

```bash
npm i @hazae41/smux
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/smux)

## Features

### Current features
- 100% TypeScript and ESM
- Zero-copy reading and writing
- Works in the browser

### [Upcoming features](https://github.com/sponsors/hazae41)
- Multiplexing

## Usage

```typescript
import { SmuxDuplex } from "@hazae41/smux"

const smux = new SmuxDuplex({ streamID: 3 })
```
npm package: @hazae41/stdbob
Description: Standard libraries for Bobine WebAssembly VM
Author: hazae41
Latest version: 0.1.3

# stdbob

Standard libraries for [Bobine WebAssembly VM](https://github.com/hazae41/bobine)

```bash
npm install @hazae41/stdbob
```

[**📦 NPM**](https://www.npmjs.com/package/@hazae41/stdbob)

## Usage

### AssemblyScript

Just import the library from your AssemblyScript file

```tsx
import { modules, blobref } from "@hazae41/stdbob"

export function main(): blobref {
  return modules.self()
}
```

And compile with `reference-types` enabled and `stub` runtime 

```bash
asc ./mod.ts -o ./mod.wasm --runtime stub --enable reference-types
```

Then deploy the .wasm file to your Bobine VM
npm package: @hazae41/symbol-dispose-polyfill
Description: Polyfill for Symbol.dispose and Symbol.asyncDispose
Author: hazae41
Latest version: 1.1.2

# Symbol.dispose and Symbol.asyncDispose polyfill

Polyfill for `Symbol.dispose` and `Symbol.asyncDispose`

```bash
npm install @hazae41/symbol-dispose-polyfill
```

```bash
deno install jsr:@hazae41/symbol-dispose-polyfill
```

[**📦 NPM**](https://www.npmjs.com/package/@hazae41//symbol-dispose-polyfill) • [**📦 JSR**](https://jsr.io/@hazae41//symbol-dispose-polyfill)

## Features
- ESModules and CommonJS
- No external dependency
- Unit-tested
- `Symbol.dispose` is polyfilled as `Symbol.for("dispose")` if not available
- `Symbol.asyncDispose` is polyfilled as `Symbol.for("asyncDispose")` if not available

## Usage

### How?

ESModules 

```tsx
import "@hazae41/symbol-dispose-polyfill"
```

CommonJS

```tsx
require("@hazae41/symbol-dispose-polyfill")
```

Deno

```tsx
import "https://deno.land/x/symbol_dispose_polyfill/src/mod.ts"
```

### Where? 

You can import the polyfill **in your project entry file** or **in a specific file**, you just need to import it before anything that requires `Symbol.dispose` or `Symbol.asyncDispose`

(e.g. For a Next.js app, it can be in `_app.js`)

```tsx
/**
 * This polyfill at the top
 **/
import "@hazae41/symbol-dispose-polyfill"

/**
 * Your imports that requires Symbol.dispose to work
 **/
import { a } from "a"
import { b } from "./b.js"

/**
 * Your code that requires Symbol.dispose to work
 **/
using x = a
```