Skip to content

Instantly share code, notes, and snippets.

@MeirionHughes
Last active September 18, 2017 14:49
Show Gist options
  • Save MeirionHughes/042d257a2607b31f5ce9c95e85330f76 to your computer and use it in GitHub Desktop.
Save MeirionHughes/042d257a2607b31f5ce9c95e85330f76 to your computer and use it in GitHub Desktop.
level-sublevel @v2 typing
import * as levelup from "levelup";
export = sublevel
declare namespace sublevel {
interface Hook {
(ch: any, add: (op: SublevelBatch | boolean) => void): void;
}
interface SublevelBatch<
TKey=any,
TValue=any,
TOptions=any,
TPutOptions=any,
TGetOptions=any,
TDeleteOptions=any,
TIteratorOptions=any,
TBatchOptions=any>
extends levelup.Batch {
prefix?: Sublevel<TKey, TValue, TOptions, TPutOptions, TGetOptions, TDeleteOptions, TIteratorOptions, TBatchOptions>;
}
interface Sublevel<
TKey=any,
TValue=any,
TOptions=any,
TPutOptions=any,
TGetOptions=any,
TDeleteOptions=any,
TIteratorOptions=any,
TBatchOptions=any>
extends levelup.LevelUp<
TKey,
TValue,
TOptions,
TPutOptions,
TGetOptions,
TDeleteOptions,
TIteratorOptions,
TBatchOptions,
SublevelBatch> {
sublevel(key: string): Sublevel<
TKey,
TValue,
TOptions,
TPutOptions,
TGetOptions,
TDeleteOptions,
TIteratorOptions,
TBatchOptions>
pre(hook: Hook): Function;
}
}
declare function sublevel<
TKey=any,
TValue=any,
TOptions=any,
TPutOptions=any,
TGetOptions=any,
TDeleteOptions=any,
TIteratorOptions=any,
TBatchOptions=any
>(
levelup: levelup.LevelUp<TKey, TValue, TOptions, TPutOptions, TGetOptions, TDeleteOptions, TIteratorOptions, TBatchOptions>
): sublevel.Sublevel<TKey, TValue, TOptions, TPutOptions, TGetOptions, TDeleteOptions, TIteratorOptions, TBatchOptions>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment