// Type definitions for iferr 1.0 // Project: https://github.com/shesek/iferr // Definitions by: segayuu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped type nodeCallback = (err: Error | null, ...a: T[]) => any; // Delegates to `succ` on sucecss or to `fail` on error // ex: Thing.load(123, iferr(cb, thing => ...)) declare function iferr(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback; declare namespace iferr { // Delegates to `succ` on sucecss or to `fail` on error // ex: Thing.load(123, iferr(cb, thing => ...)) function iferr(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback; // Like iferr, but also catches errors thrown from `succ` and passes to `fail` function tiferr(fail: (err: Error) => void, succ: (...result: T[]) => void): nodeCallback; // Delegate to the success function on success, throws the error otherwise // ex: Thing.load(123, throwerr(thing => ...)) function throwerr(succ: (...result: T[]) => void): nodeCallback; // Prints errors when one is passed, or does nothing otherwise // ex: Thing.load(123, printerr) function printerr(): nodeCallback; } export = iferr;