mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-28 09:25:50 +08:00
Adding denodeify definition for Q
This commit is contained in:
@@ -26,7 +26,7 @@ Q.delay("asdf", 1000).then(x => x.length);
|
||||
var eventualAdd = Q.promised((a?: number, b?: number) => a + b);
|
||||
eventualAdd(Q(1), Q(2)).then(x => x.toExponential());
|
||||
|
||||
var eventually = function (eventually) {
|
||||
var eventually = function (eventually: any) {
|
||||
return Q.delay(eventually, 1000);
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ Q.when(x, function (x) {
|
||||
Q.all([
|
||||
eventually(10),
|
||||
eventually(20)
|
||||
]).spread(function (x, y) {
|
||||
]).spread(function (x: any, y: any) {
|
||||
console.log(x, y);
|
||||
});
|
||||
|
||||
@@ -97,7 +97,7 @@ Q.when(Q(8), num => num + "!").then(str => str.split(','));
|
||||
|
||||
declare function saveToDisk(): Q.Promise<any>;
|
||||
declare function saveToCloud(): Q.Promise<any>;
|
||||
Q.allSettled([saveToDisk(), saveToCloud()]).spread(function (disk, cloud) {
|
||||
Q.allSettled([saveToDisk(), saveToCloud()]).spread(function (disk: any, cloud: any) {
|
||||
console.log("saved to disk:", disk.state === "fulfilled");
|
||||
console.log("saved to cloud:", cloud.state === "fulfilled");
|
||||
|
||||
@@ -115,3 +115,5 @@ var nodeStyle = (input: string, cb: Function) => {
|
||||
|
||||
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) => {});
|
||||
1
q/Q.d.ts
vendored
1
q/Q.d.ts
vendored
@@ -207,6 +207,7 @@ declare module Q {
|
||||
export function invoke<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function mcall<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
export function denodeify<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nfbind<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nfcall<T>(nodeFunction: Function, ...args: any[]): Promise<T>;
|
||||
export function nfapply<T>(nodeFunction: Function, args: any[]): Promise<T>;
|
||||
|
||||
Reference in New Issue
Block a user