# @types/level-ttl

> TypeScript definitions for level-ttl

Latest version **3.1.5** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/level-ttl
pnpm add @types/level-ttl
yarn add @types/level-ttl
bun add @types/level-ttl
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.1.5 |
| Published | 2023-11-07 |
| First published | 2019-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51440 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/level-ttl
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/level-ttl
- npm.io page: https://npm.io/package/@types/level-ttl

## Dependencies (2)

- [@types/levelup](https://npm.io/package/@types/levelup.md) *
- [@types/abstract-leveldown](https://npm.io/package/@types/abstract-leveldown.md) *

## Recent versions

- 3.1.5 (latest) — 2023-11-07
- 3.1.3 (ts4.3) — 2023-08-30
- 3.1.2 (ts3.6) — 2021-07-08
- 3.1.1 (ts3.1) — 2020-08-28
- 3.1.0 (ts2.8) — 2019-12-16
- 3.1.4 — 2023-10-18

## README

# Installation
> `npm install --save @types/level-ttl`

# Summary
This package contains type definitions for level-ttl (https://github.com/level/level-ttl).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/level-ttl.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/level-ttl/index.d.ts)
````ts
import { AbstractIterator, AbstractLevelDOWN, ErrorCallback } from "abstract-leveldown";
import { LevelUp } from "levelup";

declare namespace ttl {
    interface LevelTTLOptions {
        /**
         * A string for prefixing the modified database methods (i.e., put, del, batch, ttl, stop).
         */
        methodPrefix?: string | undefined;
        /**
         * Character for separating sublevel prefixes from user keys and each other. Should be outside the character (or byte) range of user keys.
         * @default ''
         */
        separator?: string | undefined;
        /**
         * Character specifying the key namespace for ttl values.
         * @default 'ttl'
         */
        namespace?: string | undefined;
        /**
         * Character specifying the key namespace for expiration values.
         * @default 'x'
         */
        expiryNamespace?: string | undefined;
        /**
         * A number specifying the frequency of internal scans for checking for expired keys.
         * @default 10000
         */
        checkFrequency?: number | undefined;
        /**
         * A number specifying the default time-to-live for new or updated values.
         * This can be overridden by explicitly setting the ttl value.
         * @default 0
         */
        defaultTTL?: number | undefined;
        /**
         * A custom storage database for the meta data.
         * If it's set, that storage will contain all the ttl meta data.
         * A use case for this would be to avoid mixing data and meta data in the same keyspace, since if it's not set, all data will be sharing the same keyspace.
         */
        sub?: LevelUp | undefined;
    }

    interface LevelTTL<K = any, V = any> extends LevelUp<AbstractLevelDOWN<K, V>, AbstractIterator<K, V>> {
        ttl(key: K, ttl: number, callback?: ErrorCallback): void;
        stop(callback?: ErrorCallback): void;
    }
}

/**
 * Augment levelup to handle a new 'ttl' option on put() and batch() that specifies
 * the number of milliseconds an entry should remain in the data store.
 * After the TTL, the entry will be automatically cleared for you.
 * @param db
 * @param opts
 * @see {@link https://github.com/level/level-ttl#usage level-ttl Usage}
 */
declare function ttl<K = any, V = any>(
    db: LevelUp<AbstractLevelDOWN<K, V>, AbstractIterator<K, V>>,
    opts?: ttl.LevelTTLOptions,
): ttl.LevelTTL<K, V>;
export = ttl;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:38 GMT
 * Dependencies: [@types/abstract-leveldown](https://npmjs.com/package/@types/abstract-leveldown), [@types/levelup](https://npmjs.com/package/@types/levelup)

# Credits
These definitions were written by [Carson Farmer](https://github.com/carsonfarmer).

---
_Source: https://npm.io/package/@types/level-ttl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
