diff --git a/README.md b/README.md index e33fb619f7..06ad480482 100755 --- a/README.md +++ b/README.md @@ -146,8 +146,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/)) 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; +}