From 03a3a4076e36799caf913738c152dc818cb464d2 Mon Sep 17 00:00:00 2001 From: Bret Little Date: Mon, 16 Sep 2013 09:35:25 -0600 Subject: [PATCH 1/2] Add leveldown module methods and fix issues with the leveldown api definition --- levelup/levelup-tests.ts | 27 +++++++++++++++++++++++++++ levelup/levelup.d.ts | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/levelup/levelup-tests.ts b/levelup/levelup-tests.ts index 7284d07346..223f3983d7 100644 --- a/levelup/levelup-tests.ts +++ b/levelup/levelup-tests.ts @@ -35,3 +35,30 @@ db.batch([{ , valueEncoding : 'json' }], (error)=> {}); +db.batch() + .del('father') + .put('name', 'Yuri Irsenovich Kim') + .put('dob', '16 February 1941') + .put('spouse', 'Kim Young-sook') + .put('occupation', 'Clown') + .write(function () { console.log('Done!') }) + +var open:boolean = db.isOpen(); +var closed:boolean = db.isClosed(); +db.createReadStream() + .on('data', function (data) { + console.log(data.key, '=', data.value) + }) + .on('error', function (err) { + console.log('Oh my!', err) + }) + .on('close', function () { + console.log('Stream closed') + }) + .on('end', function () { + console.log('Stream closed') + }) + +import leveldown = require('leveldown'); +leveldown.destroy('mypath', ()=>{}); +leveldown.repair('mypath', ()=>{}); diff --git a/levelup/levelup.d.ts b/levelup/levelup.d.ts index 8f267e3c6d..bb5af38be5 100644 --- a/levelup/levelup.d.ts +++ b/levelup/levelup.d.ts @@ -10,7 +10,6 @@ interface Batch { keyEncoding?: string; valueEncoding?: string; } - interface LevelUp { open(callback ?: (error : any) => any): void; close(callback ?: (error : any) => any): void; @@ -25,11 +24,45 @@ interface LevelUp { batch(array: Batch[], options?: { keyEncoding?: string; valueEncoding?: string; sync?: boolean }, callback?: (error?: any)=>any); batch(array: Batch[], callback?: (error?: any)=>any); + batch():LevelUpChain; + isOpen():boolean; + isClosed():boolean; + createReadStream(options?: any): any; + createKeyStream(options?: any): any; + createValueStream(options?: any): any; + createWriteStream(options?: any): any; + destroy(location: string, callback?: Function): void; + repair(location: string, callback?: Function): void; +} + +interface LevelUpChain { + put(key: any, value: any): LevelUpChain; + put(key: any, value: any, options?: { sync?: boolean }): LevelUpChain; + del(key: any): LevelUpChain; + del(key: any, options ?: { keyEncoding?: string; sync?: boolean }): LevelUpChain; + clear(): LevelUpChain; + write(callback?: (error?: any)=>any) : LevelUpChain; +} + +interface levelupOptions { + createIfMissing?: boolean; + errorIfExists?: boolean; + compression?: boolean; + cacheSize?: number; + keyEncoding?: string; + valueEncoding?: string; + db?: string } declare module "levelup" { - function levelup(hostname: string): LevelUp; + function levelup(hostname: string, options?: levelupOptions): LevelUp; export = levelup; } + +declare module "leveldown" { + + export function destroy(location: string, callback?: Function): void; + export function repair(location: string, callback?: Function): void; +} From 78167ca6f8c6a83ce65cc01e71a7a96300bfc80c Mon Sep 17 00:00:00 2001 From: Bret Little Date: Mon, 16 Sep 2013 09:43:10 -0600 Subject: [PATCH 2/2] Update README.md Update readme with Logg and Levelup references --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b20390c0ee..5a9968d6f6 100755 --- a/README.md +++ b/README.md @@ -145,8 +145,10 @@ List of Definitions * [Leaflet](https://github.com/Leaflet/Leaflet) (by [Vladimir](https://github.com/rgripper)) * [Libxmljs](https://github.com/polotek/libxmljs) (by [François de Campredon](https://github.com/fdecampredon)) * [ladda](https://github.com/hakimel/Ladda) (by [Danil Flores](https://github.com/dflor003)) +* [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle)) * [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) * [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) +* [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/))