Installation
npm install --save @types/subleveldown
Summary
This package contains type definitions for subleveldown (https://github.com/level/subleveldown).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/subleveldown.
index.d.ts
import { AbstractIterator, AbstractLevelDOWN, ErrorCallback } from "abstract-leveldown";
import { CodecOptions } from "level-codec";
import { LevelUp } from "levelup";
/** @see {@link SubDownOptions#open} */
type SubDownOpenHook = (callback: ErrorCallback) => void;
/**
* Any other options are passed along to the underlying `levelup` and `encoding-down` constructors.
* {@link https://github.com/Level/subleveldown#api See their documentation for further details}.
*/
interface SubDownOptions extends CodecOptions {
/**
* 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;
/**
* Optional open hook called when the underlying `levelup` instance has been opened.
* The hook receives a callback which must be called to finish opening.
*/
open?: SubDownOpenHook | undefined;
// TODO: Remove and inherit from constructor options from levelup package
[key: string]: any;
}
/**
* Returns a `levelup` instance that uses subleveldown to prefix the keys of the underlying store of `db`.
* Any layers that this instance may have (like `encoding-down` or `subleveldown` itself) are peeled off to get to the innermost `abstract-leveldown` compliant store (like `leveldown`).
* This ensures there is no double encoding step.
* @param db
* @param prefix If omitted, the effective prefix is two separators, e.g. `'!!'`. If `db` is already a subleveldown-powered instance, the effective prefix is a combined prefix, e.g. `'!one!!two!'`.
* @param opts
* @see {@link https://github.com/Level/subleveldown#api subleveldown API}
*/
declare function sub<K = any, V = any>(
db: LevelUp,
prefix?: string,
opts?: SubDownOptions | string,
): LevelUp<AbstractLevelDOWN<K, V>, AbstractIterator<K, V>>;
declare namespace sub {}
export = sub;
Additional Details
- Last updated: Tue, 07 Nov 2023 15:11:36 GMT
- Dependencies: @types/abstract-leveldown, @types/level-codec, @types/levelup
Credits
These definitions were written by Carson Farmer, and Dmitry Demensky.