open-index/open-npm huggingface dataset:
npm package: @scratchdb/database
Description: An easy to use database library.
Author: Alexis Tyler
Latest version: 0.0.8

# Database
An easy to use database library.

## Usage

1. Install
    ```bash
    npm i @scratchdb/database
    ```

2. Import in module
    ```ts
    import { createDatabase } from '@scratchdb/database';
    ```

3. Setup driver
    ```ts
    interface Episode {
        title: string;
    }

    interface User {
        name: string;
        alive: boolean;
        password: string;
    }

    interface Tables {
        episodes: Episode
        users: User
    }
    type ExtendPrototype<Prototype, NewFields> = NewFields & Omit<Prototype, keyof NewFields>;
    // This is the actual data stored in the table
    // Note: Booleans need to be set to numbers
    type SerialisedTables = {
        episodes: ExtendPrototype<Episode, {}>;
        users: ExtendPrototype<User, {
            alive: number;
            // Dead users will have their passwords stripped
            password: string | null;
        }>;
    };

    const db = createDatabase<SerialisedTables, Tables>('SQLite', {
        connections: [{
            uri: '/tmp/my-database-file.db'
        }]
    });
    ```

4. Profit?
    ```ts
    const episode = await db.findOne('episodes', 1);
    // {
    //     id: 1,
    //     lastUpdated: '2020-05-17T04:12:11.201Z',
    //     title: 'A happy day'
    // }

    const users = await db.find('users');
    // [{
    //     id: 1,
    //     lastUpdated: '2020-05-17T04:12:11.201Z',
    //     name: 'Alexis',
    //     alive: 1,
    //     password: 'a-secret-password'
    // }, {
    //     id: 2,
    //     lastUpdated: '2020-05-15T04:12:11.201Z',
    //     name: 'Ella',
    //     alive: 1,
    //     password: 'another-secret-password'
    // }, {
    //     id: 3,
    //     lastUpdated: '2020-05-15T04:12:11.201Z',
    //     name: 'Elvis',
    //     alive: 0,
    //     password: null
    // }]
    ```
```
npm package: @scratching-platypus/coordinate-ts
Description: A geographic coordinates (latitude/longitude) type for TypeScript with utilities for strict and tolerant comparison.
Author: Martin Kosař
Latest version: 1.0.2

<img src="./docs/assets/scratching-platypus-coordinate.png" alt="Scratching platypus" width="120" align="right"/>

### @scratching-platypus/coordinate-ts

A geographic coordinates (latitude/longitude) type for TypeScript with utilities for strict and tolerant comparison.

### Install

```
npm install @scratching-platypus/coordinate-ts
```

### Import

```TypeScript
import { Coordinate, equals, approxEquals } from "@scratching-platypus/coordinate-ts";
```

### Coordinate Type

```TypeScript
const a: Coordinate = { latitude: 50.0802767, longitude: 16.2958756 };
```

```TypeScript
const b: Coordinate = { latitude: 50.0797031, longitude: 16.2961389 };
```

### Strict Equality

```TypeScript
equals(a, b); // false
```

### Tolerant Equality

Compares latitude and longitude independently using absolute difference in degrees.

```TypeScript
approxEquals(a, b);         // false, epsilon = 1e-9
approxEquals(a, b, 1e-3);   // true
```
npm package: @scratching-platypus/geodesy-ts
Description: Vincenty’s formula in TypeScript for computing distances and azimuths between geographic coordinates.
Author: Martin Kosař
Latest version: 1.0.0

<img src="./docs/assets/scratching-platypus-geodesy.png" alt="Scratching platypus" width="120" align="right"/>

### @scratching-platypus/geodesy-ts

Vincenty’s formula in TypeScript for computing distances and azimuths between geographic coordinates.

### Install

```
npm install @scratching-platypus/geodesy-ts
```

### Types

```TypeScript
export type Ellipsoid = {
    a: number; // semi-major axis
    b: number; // semi-minor axis
    f: number; // flattening
};
```

```TypeScript
type GeodesicForwardResult = {
    coordinate: Coordinate; // target coordinate
    finalAzimuth: number; // target direction
};
```

```TypeScript
type GeodesicInverseResult = {
    distance: number; // distance between A and B (meters)
    initialAzimuth: number; // azimuth A -> B (degrees)
    finalAzimuth: number; // azimuth B -> A (degrees)
};
```

`Coordinate` is provided by [@scratching-platypus/coordinate-ts](https://github.com/scratching-platypus/coordinate-ts)

### Geodesy

All geodesic functions accept an optional ellipsoid parameter. If omitted, the WGS84 ellipsoid is used by default.

```TypeScript
import { vincentyInverse } from "@scratching-platypus/geodesy-ts";

vincentyInverse(A, B)                       // implicit WGS84
vincentyInverse(A, B, GRS80)                // custom ellipsoid
vincentyInverse(A, B, { a: 1: b: 1: f: 0 }) // sphere
```

```TypeScript
import { vincentyForward } from "@scratching-platypus/geodesy-ts";

vincentyForward(A, initialAzimuth, direction)                       // implicit WGS84
vincentyForward(A, initialAzimuth, direction, GRS80)                // custom ellipsoid
vincentyForward(A, initialAzimuth, direction, { a: 1: b: 1: f: 0 }) // sphere
```
npm package: @scratching-platypus/vector-ts
Description: Immutable 3D vector type for TypeScript
Author: Martin Kosař
Latest version: 1.0.2

<img src="./docs/assets/scratching-platypus-vector.png" alt="Scratching platypus" width="120" align="right"/>

### @scratching-platypus/vector-ts

**Immutable 3D vector type for TypeScript**

A small, explicit, mathematically honest vector utility with predictable behavior.

### Install

```
npm install @scratching-platypus/vector-ts
```

### Import

```TypeScript
import { Vector } from "@scratching-platypus/vector-ts";
```

### Creation

```TypeScript
const v = Vector.from(1, 2, 3);
const w = Vector.fromArray([4, 5, 6]);
```

### Unit Vectors

```TypeScript
Vector.unitX    // Vector(1, 0, 0)
Vector.unitY    // Vector(0, 1, 0)
Vector.unitZ    // Vector(0, 0, 1)
Vector.zero     // Vector(0, 0, 0)
```

### Arithmetic Operations

```TypeScript
Vector.add(a, b);
Vector.subtract(a, b);
Vector.multiply(vector, scalar);
Vector.divide(vector, scalar);
```

### Scalar and Vector Products

```TypeScript
Vector.dot(a, b);
Vector.cross(a, b);
```

### Length and Distances

```TypeScript
vector.length;
Vector.distance(a, b);
Vector.distanceSquared(a, b);
Vector.direction(a, b);
```

### Comparing

```TypeScript
v.equals(w);            // strict equality
v.approxEquals(w);      // tolerant equality
v.isZero();             // zero vector test
```

### Normalization and Negation

```TypeScript
v.unit();       // unit vector
v.normalize();  // alias of v.unit()
v.negate();     // opposite vector
```

### Angles

```TypeScript
v.angleTo(w);          // radians, in [-π, π]
v.angleTo(w, normal);  // oriented radians, in [-π, π]
```

### Rotation

```TypeScript
v.rotate(axis, degrees);    // Rodrigues' rotation formula
```

### Utilities

```TypeScript
v.toArray();   // [x, y, z]
v.toString();  // "[1.00000, 2.00000, 3.00000]"
```