From 771654d5a9add746e5655641661d37fdfb8cad52 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 22 Jun 2018 13:07:15 +0200 Subject: [PATCH] Add memdown --- blakejs/index.d.ts | 4 +- memdown/LICENSE | 21 ++++++ memdown/README.md | 16 +++++ memdown/index.d.ts | 148 +++++++++++++++++++++++++++++++++++++++++++ memdown/package.json | 24 +++++++ 5 files changed, 211 insertions(+), 2 deletions(-) create mode 100644 memdown/LICENSE create mode 100644 memdown/README.md create mode 100644 memdown/index.d.ts create mode 100644 memdown/package.json diff --git a/blakejs/index.d.ts b/blakejs/index.d.ts index f0700d3..b3cd7d0 100644 --- a/blakejs/index.d.ts +++ b/blakejs/index.d.ts @@ -14,7 +14,7 @@ type BlakeJsContext = { outlen: number }; -type blakejs = { +interface blakejs { blake2b: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => Uint8Array, blake2bFinal: (context: BlakeJsContext) => Uint8Array, blake2bHex: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => string, @@ -25,7 +25,7 @@ type blakejs = { blake2sHex: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => string, blake2sInit: (outlen?: number, key?: Uint8Array) => BlakeJsContext, blake2sUpdate: (context: BlakeJsContext, data: Buffer | Uint8Array | string) => void -}; +} export = blakejs; } diff --git a/memdown/LICENSE b/memdown/LICENSE new file mode 100644 index 0000000..4b1ad51 --- /dev/null +++ b/memdown/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/memdown/README.md b/memdown/README.md new file mode 100644 index 0000000..d2499a4 --- /dev/null +++ b/memdown/README.md @@ -0,0 +1,16 @@ +# Installation +> `npm install --save @types/leveldown` + +# Summary +This package contains type definitions for LevelDown (https://github.com/level/leveldown). + +# Details +Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/leveldown + +Additional Details + * Last updated: Fri, 05 May 2017 04:05:52 GMT + * Dependencies: node + * Global values: none + +# Credits +These definitions were written by Thiago de Arruda . diff --git a/memdown/index.d.ts b/memdown/index.d.ts new file mode 100644 index 0000000..60ea2e2 --- /dev/null +++ b/memdown/index.d.ts @@ -0,0 +1,148 @@ +// Type definitions for LevelDown 3.0.0 +// Project: https://github.com/level/memdown +// Definitions by: Thiago de Arruda +// Jaco Greeff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module 'memdown' { +export = memdown; + +var memdown: memdown.Constructor; + +namespace memdown { + type Bytes = string | Buffer; + type ErrCallback = (error: any) => void; + type ErrNumberCallback = (error: any, value: number) => void; + type ErrBufferCallback = (error: any, value: Buffer) => void; + type ErrStringCallback = (error: any, value: string) => void; + type KeyAsStringCallback = (error: any, key: string, value: Buffer) => void; + type ValueAsStringCallback = (error: any, key: Buffer, value: string) => void; + type KeyAndValueAsStringCallback = (error: any, key: string, value: string) => void; + type KeyAndValueAsBufferCallback = (error: any, key: Buffer, value: Buffer) => void; + + interface PutBatch { + type: "put"; + key: Bytes; + value: Bytes; + } + + interface DelBatch { + type: "del"; + key: Bytes; + } + + type Batch = PutBatch | DelBatch; + + interface OpenOptions { + createIfMissing?: boolean; + errorIfExists?: boolean; + compression?: boolean; + cacheSize?: number; + } + + interface OpenAdvancedOptions extends OpenOptions { + writeBufferSize?: number; + blockSize?: number; + maxOpenFiles?: number; + blockRestartInterval?: number; + maxFileSize?: number; + } + + interface WriteOptions { + sync?: boolean; + } + + interface ReadOptions { + fillCache?: boolean; + } + + interface BufferReadOptions extends ReadOptions { + asBuffer?: true; + } + + interface StringReadOptions extends ReadOptions { + asBuffer: false; + } + + interface IteratorOptions { + gt?: Bytes; + lt?: Bytes; + gte?: Bytes; + lte?: Bytes; + reverse?: boolean; + keys?: boolean; + values?: boolean; + limit?: number; + fillCache?: boolean; + } + + interface KeyAsStringIteratorOptions extends IteratorOptions { + keyAsBuffer: false; + valueAsBuffer?: true; + } + + interface ValueAsStringIteratorOptions extends IteratorOptions { + keyAsBuffer?: true; + valueAsBuffer: false; + } + + interface KeyAndValueAsStringIteratorOptions extends IteratorOptions { + keyAsBuffer: false; + valueAsBuffer: false; + } + + interface KeyAndValueAsBufferIteratorOptions extends IteratorOptions { + keyAsBuffer?: true; + valueAsBuffer?: true; + } + + interface Iterator { + seek(key: Bytes): void; + end(callback: ErrCallback): void; + } + + interface KeyAsStringIterator extends Iterator { + next(callback: KeyAsStringCallback): void; + } + + interface ValueAsStringIterator extends Iterator { + next(callback: ValueAsStringCallback): void; + } + + interface KeyAndValueAsStringIterator extends Iterator { + next(callback: KeyAndValueAsStringCallback): void; + } + + interface KeyAndValueAsBufferIterator extends Iterator { + next(callback: KeyAndValueAsBufferCallback): void; + } + + interface MemDown { + open(callback: ErrCallback): void; + open(options: OpenOptions, callback: ErrCallback): void; + close(callback?: ErrCallback): void; + put(key: Bytes, value: Bytes, callback: ErrCallback): void; + put(key: Bytes, value: Bytes, options: WriteOptions, callback: ErrCallback): void; + get(key: Bytes, callback: ErrBufferCallback): void; + get(key: Bytes, options: BufferReadOptions, callback: ErrBufferCallback): void; + get(key: Bytes, options: StringReadOptions, callback: ErrStringCallback): void; + del(key: Bytes, callback?: ErrCallback): void; + del(key: Bytes, options: WriteOptions, callback?: ErrCallback): void; + batch(operations: Batch[], callback?: ErrCallback): void; + batch(operations: Batch[], options?: WriteOptions, callback?: ErrCallback): void; + approximateSize(start: Bytes, end: Bytes, callback: ErrNumberCallback): void; + compactRange(start: Bytes, end: Bytes, callback: ErrCallback): void; + getProperty(property: string): string; + iterator(options?: KeyAsStringIteratorOptions): KeyAsStringIterator; + iterator(options?: ValueAsStringIteratorOptions): ValueAsStringIterator; + iterator(options?: KeyAndValueAsStringIteratorOptions): KeyAndValueAsStringIterator; + iterator(options?: KeyAndValueAsBufferIteratorOptions): KeyAndValueAsBufferIterator; + destroy(location: string, callback: ErrCallback): void; + repair(location: string, callback: ErrCallback): void; + } + + type Constructor = () => MemDown; +} +} diff --git a/memdown/package.json b/memdown/package.json new file mode 100644 index 0000000..9a0f748 --- /dev/null +++ b/memdown/package.json @@ -0,0 +1,24 @@ +{ + "name": "@types/leveldown", + "version": "1.7.0", + "description": "TypeScript definitions for LevelDown", + "license": "MIT", + "contributors": [ + { + "name": "Thiago de Arruda", + "url": "https://github.com/tarruda" + } + ], + "main": "", + "repository": { + "type": "git", + "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" + }, + "scripts": {}, + "dependencies": { + "@types/node": "*" + }, + "peerDependencies": {}, + "typesPublisherContentHash": "8ad2a943006b3c5296b92869b9a520d84e733c731edabe2e500821f18f35b56f", + "typeScriptVersion": "2.0" +} \ No newline at end of file