open-index/open-npm huggingface dataset:
npm package: @hazae41/memory-wasm
Description: Zero-copy memory for WebAssembly
Author: hazae41
Latest version: 2.0.0

# memory.wasm

Zero-copy memory for WebAssembly

```bash
npm install @hazae41/memory-wasm
```

```bash
deno install jsr:@hazae41/memory-wasm
```

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

## Features
- Reproducible building
- Pre-bundled and streamed
- Zero-copy memory slices

## Usage

```typescript
import { exampleWasm } from "@hazae41/example-wasm";

// Wait for initialization
await exampleWasm.initBundled();

// Pass bytes to memory
using memory = new exampleWasm.Memory();

// View bytes from memory
console.log(memory.bytes)

// Call method with 0-copy
exampleWasm.example_method(memory)
```

## Building

### Reproducible building

You can build the exact same bytecode using Docker

```bash
npm run compile
```

Then check that all the files are the same using `npm diff`

```bash
npm diff
```

If the output is empty then the bytecode is the same as the one I published on NPM.

### Automated checks

Each time I release a new version on GitHub, the GitHub's CI clones the GitHub repository, reproduces the build, and throws an error if the NPM release is different. If a version is present on NPM but not on GitHub, do not use it!
npm package: @hazae41/memory.wasm
Description: Zero-copy memory for WebAssembly
Author: hazae41
Latest version: 1.0.37
Deprecated: Please use @hazae41/memory-wasm (with a hyphen instead of a dot)

# memory.wasm

Zero-copy memory for WebAssembly

```bash
npm install @hazae41/memory.wasm
```

```bash
deno install jsr:@hazae41/memory-wasm
```

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

## Features
- Reproducible building
- Pre-bundled and streamed
- Zero-copy memory slices

## Usage

```typescript
import { ExampleWasm, Memory, example_method } from "@hazae41/example.wasm";

// Wait for initialization
await ExampleWasm.initBundled();

// Pass bytes to memory
using memory = new Memory();

// View bytes from memory
console.log(memory.bytes)

// Call method with 0-copy
example_method(memory)
```

## Building

### Reproducible building

You can build the exact same bytecode using Docker

```bash
npm run compile
```

Then check that all the files are the same using `npm diff`

```bash
npm diff
```

If the output is empty then the bytecode is the same as the one I published on NPM.

### Automated checks

Each time I release a new version on GitHub, the GitHub's CI clones the GitHub repository, reproduces the build, and throws an error if the NPM release is different. If a version is present on NPM but not on GitHub, do not use it!
npm package: @hazae41/mutex
Description: Rust-like Mutex for TypeScript
Author: hazae41
Latest version: 3.0.1

# Mutex

Rust-like Mutex and Semaphore for TypeScript

```bash
npm install @hazae41/mutex
```

```bash
deno install jsr:@hazae41/mutex
```

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

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Similar to Rust
- Can hold data
- Unit-tested
- Memory-safe

## Usage

### Mutex

```typescript
import { Mutex } from "@hazae41/mutex"

const mutex = new Mutex(123)

/**
 * You can queue a callback 
 */
async function runOrWait() {
  await mutex.runOrWait((x) => /* do (async) stuff with x */)
}

/**
 * You can throw if the mutex is already locked
 */
async function runOrThrow() {
  await mutex.runOrThrow((x) => /* do stuff with x */)
}

/**
 * You can return something from the callback
 */
async function runOrWait2() {
  const y = await mutex.runOrWait((x) => x * 2)
}

/**
 * You can use async code
 */
async function runOrWait3() {
  const y = await mutex.runOrWait(async (x) => await f(x))
}

/**
 * You can acquire and release when you want
 */
async function getOrWait() {
  const x = await mutex.getOrWait()
  const y = x.get() * 2
  x.release()
}

/**
 * You can acquire and release with `using`
 */
async function getOrWait2() {
  using x = await mutex.getOrWait()
  const y = x.get() * 2
}
```

### Semaphore

Same functions as Mutex but you can specify a capacity

```tsx
const semaphore = new Semaphore(123, 3)

const a = await semaphore.getOrThrow()
const b = await semaphore.getOrThrow()
const c = await semaphore.getOrThrow()
const d = await semaphore.getOrThrow() // will throw
```

You can see it like `Mutex<T> = Semaphore<T, 1>`