// Type definitions for Lowdb 0.15 // Project: https://github.com/typicode/lowdb // Definitions by: typicode, // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Lowdb { interface PromiseLike { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } interface StringRepresentable { toString(): string; } interface List { [index: number]: T; length: number; } interface Dictionary { [index: string]: T; } interface DictionaryIterator { (value: T, key?: string, collection?: Dictionary): TResult; } interface ListIterator { (value: T, index: number, collection: List): TResult; } interface StringIterator { (char: string, index?: number, string?: string): TResult; } interface MixinOptions { chain?: boolean; } class LoDashWrapper> { /** * @see _.has */ has(path: StringRepresentable | StringRepresentable[]): LowEntryClass; /** * @see _.hasIn */ hasIn(path: StringRepresentable | StringRepresentable[]): LowEntryClass; /** * @see _.assign */ assign( source: TSource ): LowEntryClass; /** * @see _.assign */ assign( source1: TSource1, source2: TSource2 ): LowEntryClass; /** * @see _.assign */ assign( source1: TSource1, source2: TSource2, source3: TSource3 ): LowEntryClass; /** * @see _.assign */ assign( source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4 ): LowEntryClass; /** * @see _.assign */ assign(): LowEntryClass; /** * @see _.assign */ assign(...otherArgs: any[]): LowEntryClass; /** * @see _.cloneDeep */ cloneDeep(): LowEntryClass; /** * @see _.cloneDeep */ cloneDeep(): LowEntryClass; /** * @see _.cloneDeep */ cloneDeepWith(customizer: (value: any) => any): LowEntryClass[]; /** * @see _.cloneDeep */ cloneDeepWith(customizer: (value: any) => any): LowEntryClass; /** * @see _.defaults */ defaults( source1: S1, ...sources: {}[] ): LowEntryClass; /** * @see _.defaults */ defaults( source1: S1, source2: S2, ...sources: {}[] ): LowEntryClass; /** * @see _.defaults */ defaults( source1: S1, source2: S2, source3: S3, ...sources: {}[] ): LowEntryClass; /** * @see _.defaults */ defaults( source1: S1, source2: S2, source3: S3, source4: S4, ...sources: {}[] ): LowEntryClass; /** * @see _.defaults */ defaults(): LowEntryClass; /** * @see _.defaults */ defaults(...sources: {}[]): LowEntryClass; /** * @see _.get */ get(object: any, path: string | number | boolean | Array, defaultValue?: TResult ): LowEntryClass; /** * @see _.get */ get(path: string | number | boolean | Array, defaultValue?: TResult ): LowEntryClass; /** * @see _.mixin */ mixin( source: Dictionary<() => void>, options?: MixinOptions ): LowEntryClass; /** * @see _.mixin */ mixin( options?: MixinOptions ): LowEntryClass; /** * @see _.set */ set( path: StringRepresentable | StringRepresentable[], value: any ): LowEntryClass; /** * @see _.set */ set( path: StringRepresentable | StringRepresentable[], value: V ): LowEntryClass; /** * @see _.find */ find( predicate?: ListIterator, thisArg?: any ): LowEntryClass; /** * @see _.find */ find( predicate?: string, thisArg?: any ): LowEntryClass; /** * @see _.find */ find( predicate?: TObject ): LowEntryClass; /** * @see _.find */ filter( predicate?: TObject ): LowEntryClass; /** * @see _.filter */ filter( predicate?: ListIterator, thisArg?: any ): LowEntryClass; /** * @see _.filter */ filter( predicate: string, thisArg?: any ): LowEntryClass; /** * @see _.filter */ filter( predicate: ListIterator | DictionaryIterator, thisArg?: any ): LowEntryClass; /** * @see _.filter */ filter( predicate?: StringIterator, thisArg?: any ): LowEntryClass; /** * @see _.filter */ filter(predicate: W): LowEntryClass; /** * @see _.map */ map( iteratee?: ListIterator, thisArg?: any ): LowEntryClass; /** * @see _.map */ map( iteratee?: string ): LowEntryClass; /** * @see _.map */ map( iteratee?: TObject ): LowEntryClass; /** * @see _.map */ map( iteratee?: ListIterator | DictionaryIterator, thisArg?: any ): LowEntryClass; /** * @see _.range */ range( end?: number, step?: number ): LowEntryClass; /** * @see _.rangeRight */ rangeRight( end?: number, step?: number ): LowEntryClass; /** * @see _.remove */ remove( predicate?: ListIterator, thisArg?: any ): LowEntryClass; /** * @see _.remove */ remove( predicate?: string, thisArg?: any ): LowEntryClass; /** * @see _.remove */ remove( predicate?: W ): LowEntryClass; /** * @see _.sortBy */ sortBy( iteratee?: ListIterator ): LowEntryClass; /** * @see _.sortBy */ sortBy(iteratee: string): LowEntryClass; /** * @see _.sortBy */ sortBy(whereValue: W): LowEntryClass; /** * @see _.sortBy */ sortBy(): LowEntryClass; /** * @see _.sortBy */ sortBy(...iteratees: (ListIterator | any | string)[]): LowEntryClass; /** * @see _.sortBy */ sortBy(iteratees: (ListIterator | string | any)[]): LowEntryClass; /** * @see _.slice */ slice( start?: number, end?: number ): LowEntryClass; /** * @see _.size */ size(): LowEntryClass; /** * @see _.take */ take(n?: number): LowEntryClass; /** * @see _.times */ times( iteratee: (num: number) => TResult ): LowEntryClass; /** * @see _.times */ times(): LowEntryClass; /** * @see _.uniqueId */ uniqueId(): LowEntryClass; value(): T; pop(): T; push(...items: T[]): LowEntryClass; shift(): T; sort(compareFn?: (a: T, b: T) => number): LowEntryClass; splice(start: number): LowEntryClass; splice(start: number, deleteCount: number, ...items: any[]): LowEntryClass; unshift(...items: T[]): LowEntryClass; } export interface Storage { /** * Reads the database. * * @param source The source location. * @param deserialize The deserialize function to apply. * @return Returns a promise with the deserialized db object. */ read?(source: string, deserialize: any): PromiseLike /** * Reads the database. * * @param source The source location. * @param deserialize The deserialize function to apply. * @return Returns the deserialized db object. */ read?(source: string, deserialize: any): {} /** * Writes to the database. * * @param destination The destination location. * @param obj The object to write. * @param serialize The serialize function to apply. */ write?(destination: string, obj: any, serialize: any): void /** * Writes to the database. * * @param destination The destination location. * @param obj The object to write. * @param serialize The serialize function to apply. */ write?(destination: string, obj: any, serialize: any): PromiseLike } export interface Format { /** * Writes to the database. * * @param obj The object to serialize. * @return Returns the serialized object string. */ serialize(obj: any): string /** * Writes to the database. * * @param data The object to deserialize. * @return Returns the deserialized object. */ deserialize(data: string): any } export interface Options { /** * The custom "storage" object. */ storage?: Storage /** * The custom "format" object. */ format?: Format /** * The flag to automatically persist changes. */ writeOnChange?: boolean } export class Lowdb extends LoDashWrapper { constructor(filePath: string, options?: Options); /** * Access current database state. * Returns Returns the database state. */ getState(): any /** * Drop or reset database state. * @param newState New state of the database */ setState(newState: any): void /** * Persist database. * @param source The source location. */ write(source?: string): void /** * Persist database. * @param source The source location. */ write(source?: string): PromiseLike /** * Read database. * @param source The source location. */ read(source?: string): any /** * Read database. * @param source The source location. */ read(source?: string): PromiseLike } // declare class lowdb { // new (source?: string, opts?: Options): Low; // (source?: string, opts?: Options) : Low; // } } declare module "lowdb" { export = Lowdb.Lowdb; }