diff --git a/q/Q-tests.ts b/q/Q-tests.ts index 56ce130f0..48a3224bc 100644 --- a/q/Q-tests.ts +++ b/q/Q-tests.ts @@ -110,10 +110,31 @@ Q.allSettled([saveToDisk(), saveToCloud()]).spread(function (disk: any, cloud: a }).done(); var nodeStyle = (input: string, cb: Function) => { - cb(null, input); + cb(null, input); }; Q.nfapply(nodeStyle, ["foo"]).done((result: string) => {}); Q.nfcall(nodeStyle, "foo").done((result: string) => {}); Q.denodeify(nodeStyle)('foo').done((result: string) => {}); -Q.nfbind(nodeStyle)('foo').done((result: string) => {}); \ No newline at end of file +Q.nfbind(nodeStyle)('foo').done((result: string) => {}); + + +class Repo { + private items: any[] = [ + { name: 'Max', cute: false }, + { name: 'Annie', cute: true } + ]; + + find(options: any): Q.Promise { + var result = this.items; + + for (var key in options) { + result = result.filter(i => i[key] == options[key]); + } + + return Q(result); + } +} + +var kitty = new Repo(); +Q.nbind(kitty.find, kitty)({ cute: true }).done((kitties: any[]) => {}); \ No newline at end of file diff --git a/q/Q.d.ts b/q/Q.d.ts index 1d76edd1d..8e9696be5 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -208,6 +208,7 @@ declare module Q { export function mcall(obj: any, functionName: string, ...args: any[]): Promise; export function denodeify(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; + export function nbind(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise; export function nfbind(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; export function nfcall(nodeFunction: Function, ...args: any[]): Promise; export function nfapply(nodeFunction: Function, args: any[]): Promise;