mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-11 12:40:15 +00:00
Merge pull request #1051 from blittle/master
Fix issues with the Levelup API definitions
This commit is contained in:
@@ -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/))
|
||||
|
||||
@@ -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', ()=>{});
|
||||
|
||||
37
levelup/levelup.d.ts
vendored
37
levelup/levelup.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user