mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
adds typings for the 'RocksDB' package
This commit is contained in:
parent
23151ac95a
commit
46eedd5555
89
types/rocksdb/index.d.ts
vendored
Normal file
89
types/rocksdb/index.d.ts
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
// Type definitions for rocksdb 3.0
|
||||
// Project: https://github.com/Level/rocksdb
|
||||
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
|
||||
// Daniel Byrne <https://github.com/danwbyrne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import {
|
||||
AbstractLevelDOWN,
|
||||
AbstractIteratorOptions,
|
||||
AbstractIterator,
|
||||
AbstractOpenOptions,
|
||||
AbstractGetOptions,
|
||||
ErrorCallback,
|
||||
ErrorValueCallback,
|
||||
AbstractChainedBatch,
|
||||
AbstractBatch,
|
||||
AbstractOptions
|
||||
} from 'abstract-leveldown';
|
||||
|
||||
interface RocksDB extends AbstractLevelDOWN<RocksDB.Bytes, RocksDB.Bytes> {
|
||||
open(cb: ErrorCallback): void;
|
||||
open(options: RocksDB.OpenOptions, cb: ErrorCallback): void;
|
||||
|
||||
get(key: RocksDB.Bytes, cb: ErrorValueCallback<RocksDB.Bytes>): void;
|
||||
get(key: RocksDB.Bytes, options: RocksDB.GetOptions, cb: ErrorValueCallback<RocksDB.Bytes>): void;
|
||||
|
||||
put(key: RocksDB.Bytes, value: RocksDB.Bytes, cb: ErrorCallback): void;
|
||||
put(key: RocksDB.Bytes, value: RocksDB.Bytes, options: RocksDB.PutOptions, cb: ErrorCallback): void;
|
||||
|
||||
del(key: RocksDB.Bytes, cb: ErrorCallback): void;
|
||||
del(key: RocksDB.Bytes, options: RocksDB.DelOptions, cb: ErrorCallback): void;
|
||||
|
||||
batch(): AbstractChainedBatch<RocksDB.Bytes, RocksDB.Bytes>;
|
||||
batch(array: AbstractBatch[], cb: ErrorCallback): AbstractChainedBatch<RocksDB.Bytes, RocksDB.Bytes>;
|
||||
batch(array: AbstractBatch[], options: RocksDB.BatchOptions, cb: ErrorCallback): AbstractChainedBatch<RocksDB.Bytes, RocksDB.Bytes>;
|
||||
|
||||
approximateSize(start: RocksDB.Bytes, end: RocksDB.Bytes, cb: RocksDB.ErrorSizeCallback): void;
|
||||
compactRange(start: RocksDB.Bytes, end: RocksDB.Bytes, cb: ErrorCallback): void;
|
||||
getProperty(property: string): string;
|
||||
destroy(location: string, cb: ErrorCallback): void;
|
||||
repair(location: string, cb: ErrorCallback): void;
|
||||
iterator(options?: RocksDB.IteratorOptions): RocksDB.Iterator;
|
||||
}
|
||||
|
||||
declare namespace RocksDB {
|
||||
type Bytes = string | Buffer;
|
||||
type ErrorSizeCallback = (err: Error | undefined, size: number) => void;
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
interface OpenOptions extends AbstractOpenOptions {}
|
||||
|
||||
interface GetOptions extends AbstractGetOptions {
|
||||
fillCache?: boolean;
|
||||
}
|
||||
|
||||
interface PutOptions extends AbstractOptions {
|
||||
sync?: boolean;
|
||||
}
|
||||
|
||||
interface DelOptions extends AbstractOptions {
|
||||
sync?: boolean;
|
||||
}
|
||||
|
||||
interface BatchOptions extends AbstractOptions {
|
||||
sync?: boolean;
|
||||
}
|
||||
|
||||
interface IteratorOptions extends AbstractIteratorOptions<Bytes> {
|
||||
fillCache?: boolean;
|
||||
}
|
||||
|
||||
interface Iterator extends AbstractIterator<Bytes, Bytes> {
|
||||
seek(key: Bytes): void;
|
||||
binding: any;
|
||||
cache: any;
|
||||
finished: any;
|
||||
fastFuture: any;
|
||||
}
|
||||
|
||||
interface Constructor {
|
||||
new(location: string): RocksDB;
|
||||
(location: string): RocksDB;
|
||||
}
|
||||
}
|
||||
|
||||
declare const RocksDB: RocksDB.Constructor;
|
||||
export default RocksDB;
|
||||
19
types/rocksdb/rocksdb-tests.ts
Normal file
19
types/rocksdb/rocksdb-tests.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import RocksDB from 'rocksdb';
|
||||
|
||||
// can use 'new', or not.
|
||||
const a = new RocksDB("./tmp/rocksdb");
|
||||
const b = RocksDB("./tmp/rocksdb");
|
||||
|
||||
const down = new RocksDB("./tmp/rocksdb");
|
||||
|
||||
down.open(() => {
|
||||
down.put("key", "value", (err?) => { });
|
||||
down.put(Buffer.from([1]), "value", { something: true }, (err?) => { });
|
||||
|
||||
down.get("key", (err?) => { });
|
||||
down.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: any) => { });
|
||||
|
||||
down.close(() => {
|
||||
// do nothing
|
||||
});
|
||||
});
|
||||
23
types/rocksdb/tsconfig.json
Normal file
23
types/rocksdb/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"rocksdb-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/rocksdb/tslint.json
Normal file
1
types/rocksdb/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user