open-index/open-npm huggingface dataset:
npm package: @caolan/timi
Description: JavaScript indexes with transactions
Author: Caolan McMahon
Latest version: 0.1.1

# Timi

A JavaScript library to build database-style indexes in memory. It uses
B+trees with some advanced features:

* Fast sorted-order iteration
* Optional duplicate key support
* Transactions: both nested and spanning multiple indexes
* And cheap immutable snapshots

Timi is written using plain JavaScript modules with no external
dependencies.

## Download

Source code:

* [timi-main.tar.gz](https://caolan.uk/src/timi/snapshot/timi-main.tar.gz)
* [timi-main.tar.bz2](https://caolan.uk/src/timi/snapshot/timi-main.tar.bz2)
* [timi-main.tar.zip](https://caolan.uk/src/timi/snapshot/timi-main.tar.zip)

NPM package:

```plain
npm install @caolan/timi
```

## Example

```javascript
import { Transaction, Index } from "timi.js";

// All data lives within a transaction.
const txn = new Transaction();

// Create an index.
const tasks = txn.create(new Index('number'));

// Add some data to the index.
tasks.put(txn, 1, 'Try Timi');
tasks.put(txn, 2, 'Have a cup of tea');
tasks.put(txn, 3, 'Eat some cake');

// Read a given key.
const description = tasks.get(txn, 2);

// Iterate over all entries
tasks.entries(txn, (id, description) => {
    console.log(`${id}: ${description}`);
});
```

## Documentation

[API Reference](https://caolan.uk/src/timi/plain/docs/index.html)

## Tests

The unit tests are written for [Deno](https://deno.com).

```
deno test
```

## Benchmarks

Despite the extra features, Timi benchmarks favourably against
all JavaScript B-tree/B+tree implementations that I've found.
If you know of another library, or you believe I'm using a library
incorrectly, please contact me so I can update the benchmarks.

[B-Tree benchmarks](https://caolan.uk/src/timi-benchmarks/plain/index.html)

## Support

There is no public issue tracker yet. I'd be grateful for an email
with your bug reports or feedback. As with all my libraries, commercial
support is available.

[caolan@caolan.uk](mailto:caolan@caolan.uk)