Socket
Book a DemoInstallSign in
Socket

@caolan/timi

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@caolan/timi

JavaScript indexes with transactions

0.1.1
latest
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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
  • timi-main.tar.bz2
  • timi-main.tar.zip

NPM package:

npm install @caolan/timi

Example

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

Tests

The unit tests are written for Deno.

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

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

Keywords

key

FAQs

Package last updated on 27 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.