open-index/open-npm huggingface dataset:
npm package: @hazae41/cleaner
Description: Helpers for Disposable
Author: hazae41
Latest version: 2.0.9
Deprecated: Moved to @hazae41/disposer

# Cleaner

Helpers for Disposable

```bash
npm i @hazae41/cleaner
```

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

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Create a disposable object from any object
- Create a thenable disposable object from a thenable object
- Race multiple thenable and disposable objects

## Usage

### Create a disposable object (Disposable or AsyncDisposable) from any object

```tsx
using d = new Disposer(something, () => { ... })
```

```tsx
await using d = new AsyncDisposer(something, async () => { ... })
```

### Create a thenable disposable object from a thenable object (PromiseLike)

```tsx
using d = new PromiseDisposer(doSomethingAsync(), () => { ... })

await d
```

```tsx
await using d = new AsyncPromiseDisposer(doSomethingAsync(), async () => { ... })

await d
```

### Race multiple thenable and disposable objects (PromiseLike & Disposable)

It will dispose both a and b once one of them settles

```tsx
/**
 * When a and b are Disposable
 **/
await Disposable.raceSync([a, b])
```

```tsx
/**
 * When a and b are AsyncDisposable
 **/
await Disposable.race([a, b])
```

This can be useful for waiting for multiple listeners, and remove all listeners when one of them is triggered

```tsx
function waitA(): PromiseLike<"a"> & Disposable {
  const future = new Future<"a">()
  const onevent = () => future.resolve("a")

  this.addEventListener("a", onevent)
  const off = () => this.removeEventListener("a", onevent)
  
  return new PromiseDisposer(future.promise, off)
}

function waitB(): PromiseLike<"b"> & Disposable {
  const future = new Future<"b">()
  const onevent = () => future.resolve()

  this.addEventListener("b", onevent)
  const off = () => this.removeEventListener("b", onevent)
  
  return new PromiseDisposer(future.promise, off)
}

/**
 * When one listener is triggered, the other is removed
 **/
const x: "a" | "b" = await Disposable.raceSync([waitA(), waitB()])
```
npm package: @hazae41/clonable
Description: Rust-like clone for TypeScript
Author: hazae41
Latest version: 1.0.6

# Clonable

Rust-like clone for TypeScript

```bash
npm i @hazae41/clonable
```

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

## Features
- 100% TypeScript and ESM
- Rust-like patterns

## Usage
 
```tsx
import { Clonable, Slice } from "@hazae41/clonable"

class Struct implements Clonable {

  constructor(
    readonly slice: Slice
  ) {}

  cloneOrThrow(): this {
    return new Struct(this.slice.cloneOrThrow())
  }

}
```
npm package: @hazae41/cursor
Description: Rust-like Cursor for TypeScript
Author: hazae41
Latest version: 2.1.3

# Cursor

Rust-like Cursor for TypeScript

```bash
npm install @hazae41/cursor
```

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

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

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- Zero-copy reading and writing
- Rust-like patterns
- Unit-tested

## Usage

### Cursor

#### Writing

```typescript
const cursor = new Cursor(new Uint8Array(1024))

cursor.writeUint8OrThrow(123)
cursor.writeUint16OrThrow(1234)

console.log(cursor.offset) // 3
```

#### Reading

```typescript
const cursor = new Cursor(new Uint8Array(/*...*/))

const uint8 = cursor.readUint8OrThrow()
const uint16 = cursor.readUint16OrThrow()

console.log(cursor.offset) // 3
```
npm package: @hazae41/decibel
Description: Queriable in-memory database for TypeScript
Author: hazae41
Latest version: 2.0.0

# Decibel

Queriable in-memory database for TypeScript

```bash
npm i @hazae41/decibel
```

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

## Features

### Current features
- 100% TypeScript and ESM
- No external dependencies
- NoSQL-like querying

## Usage

```tsx
const db = new Database()

db.append({
  id: "1",
  name: "John",
  age: 30,
  job: "Engineer",
  certifications: ["AWS", "Azure", "GCP"]
})

db.append({
  id: "2",
  name: "Jane",
  age: 30,
  job: "Engineer",
  certifications: ["AWS", "Azure", "Docker"]
})

/**
 * Find people whose job is `Engineer` and who have the `GCP` certification, order by ascending age, then order by descending id if they have the same age
 */
const [john] = db.get({ age: "ascending", id: "descending" }, { job: "Engineer", certifications: ["GCP"] })
```

- Any column that can be converted to `number` will be orderable (e.g. `0.1`, `"0.1"`, `1n`, `"0x1"`)
- Arrays are filtered with inter / inner join / "and" (e.g. `["GCP", "AWS"]` -> arrays containing both `Azure` and `GCP`)