typeson
Version:
Preserves types over JSON, BSON or socket.io
66 lines • 2.17 kB
TypeScript
/**
* We keep this function minimized so if using two instances of this
* library, where one is minimized and one is not, it will still work
* with `hasConstructorOf`.
* With ES6 classes, we may be able to simply use `class TypesonPromise
* extends Promise` and add a string tag for detection.
* @template T
*/
export class TypesonPromise<T> {
/**
* @param {(
* resolve: (value: any) => any,
* reject: (reason?: any) => void
* ) => void} f
*/
constructor(f: (resolve: (value: any) => any, reject: (reason?: any) => void) => void);
p: Promise<any>;
/**
*
* @param {?(value: T) => any} [onFulfilled]
* @param {(reason?: any) => any} [onRejected]
* @returns {TypesonPromise<T>}
*/
then(onFulfilled?: ((value: T) => any) | null, onRejected?: (reason?: any) => any): TypesonPromise<T>;
/**
*
* @param {(reason?: any) => void} onRejected
* @returns {TypesonPromise<T>}
*/
catch(onRejected: (reason?: any) => void): TypesonPromise<T>;
}
export namespace TypesonPromise {
let __typeson__type__: string;
/**
* @template T
* @param {T} v
* @returns {TypesonPromise<T>}
*/
function resolve<T_1>(v: T_1): TypesonPromise<T_1>;
/**
* @template T
* @param {any} v
* @returns {TypesonPromise<T>}
*/
function reject<T_1>(v: any): TypesonPromise<T_1>;
/**
*
* @template T
* @param {(TypesonPromise<T>|Promise<T>|any)[]} promArr
* @returns {TypesonPromise<T>}
*/
function all<T_1>(promArr: (TypesonPromise<T_1> | Promise<T_1> | any)[]): TypesonPromise<T_1>;
/**
* @template T
* @param {(TypesonPromise<T>|Promise<T>|null)[]} promArr
* @returns {TypesonPromise<T>}
*/
function race<T_1>(promArr: (TypesonPromise<T_1> | Promise<T_1> | null)[]): TypesonPromise<T_1>;
/**
* @template T
* @param {(TypesonPromise<T>|Promise<T>|null)[]} promArr
* @returns {TypesonPromise<T>}
*/
function allSettled<T_1>(promArr: (TypesonPromise<T_1> | Promise<T_1> | null)[]): TypesonPromise<T_1>;
}
//# sourceMappingURL=TypesonPromise.d.ts.map