Merge pull request #14163 from yyc-git/master

add cannon,rsvp,wonder-commonlib,wonder-frp dts file
This commit is contained in:
Horiuchi_H
2017-01-23 17:21:13 +09:00
committed by GitHub
12 changed files with 2633 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
import cannon = require("cannon");
var aabb = new cannon.AABB()
aabb.setFromPoints([new cannon.Vec3(1,2,3)]);
+1205
View File
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cannon-tests.ts"
]
}
+319
View File
@@ -0,0 +1,319 @@
// Type definitions for RSVP 3.0.9
// Project: github.com/tildeio/rsvp.js 3.0.9
// Definitions by: Taylor Brown <https://github.com/Taytay>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Some of this file was taken from the type definitions for es6-promise https://github.com/borisyankov/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
// Credit for that file goes to: François de Campredon <https://github.com/fdecampredon/>
// Some of this file was taken from the type definitions for Q : https://github.com/borisyankov/DefinitelyTyped/blob/master/q/Q.d.ts
// Credit for that file goes to: Barrie Nemetchek <https://github.com/bnemetchek>, Andrew Gaspar <https://github.com/AndrewGaspar/>, John Reilly <https://github.com/johnnyreilly>
declare module RSVP {
interface Thenable<R> {
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => U): Thenable<U>;
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => void): Thenable<U>;
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => U): Thenable<U>;
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => void): Thenable<U>;
}
interface Deferred<T> {
promise: Promise<T>;
resolve(value: T): void;
reject(reason: any): void;
}
class Promise<R> implements Thenable<R> {
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise is fulfilled with result object passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback:(resolve:(result?:R) => void, reject:(error:any) => void) => void, label? : string);
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise will be fulfilled/rejected with the outcome of thenable passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback:(resolve:(thenable?:Thenable<R>) => void, reject:(error:any) => void) => void, label? : string);
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => Thenable<U>):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => U):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => void):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => Thenable<U>):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => U):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => void):Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?:(error:any) => Thenable<U>):Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?:(error:any) => U):Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?:(error:any) => void):Promise<U>;
finally(finallyCallback: () => any): Promise<R>;
static all<T>(promises: Thenable<T>[]): Promise<T[]>;
static all<T>(promises: any[]): Promise<T[]>;
static race<R>(promises:Promise<R>[]):Promise<R>;
/**
@method resolve
@param {Any} value value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
static resolve<T>(object: Thenable<T>): Promise<T>;
static resolve<T>(object: T): Promise<T>;
/**
@method cast (Deprecated in favor of resolve
@param {Any} value value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
static cast<T>(object: Thenable<T>, label? : string): Promise<T>;
static cast<T>(object: T, label? : string): Promise<T>;
/**
`RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
*/
static reject(reason?: any): Promise<any>;
}
interface PromiseState<T> {
state: string /* "fulfilled", "rejected", "pending" */;
value?: T;
reason?: any;
}
interface InstrumentEvent{
guid:string; // guid of promise. Must be globally unique, not just within the implementation
childGuid:string; // child of child promise (for chained via `then`)
eventName:string; // one of ['created', 'chained', 'fulfilled', 'rejected']
detail:any; // fulfillment value or rejection reason, if applicable
label:string; // label passed to promise's constructor
timeStamp:number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now
}
export function on(eventName : string, callback: (value:any)=>void) : void;
export function on(eventName : "error", errorHandler: (reason:any)=>void): void;
export function on(eventName : "created", listener: (event:InstrumentEvent)=>void): void;
export function on(eventName : "chained", listener: (event:InstrumentEvent)=>void): void;
export function on(eventName : "fulfilled", listener: (event:InstrumentEvent)=>void): void;
export function on(eventName : "rejected", listener: (event:InstrumentEvent)=>void): void;
export function configure(configName : string, value : any): void;
export function configure(configName : "instrument", shouldInstrument : boolean): void;
/**
* configure('onerror', handler) is deprecated in favor of on('error', handler)
* @param configName
* @param errorHandler
*/
export function configure(configName : "onerror", errorHandler : (reason:any)=>void): void;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
*/
export function all<T>(promises: Thenable<T>[]): Promise<T[]>;
export function all<T>(promises: any[]): Promise<T[]>;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
* The key difference to the all() function is that both the fulfillment value and the argument to the hash() function
* are object literals. This allows you to simply reference the results directly off the returned object without
* having to remember the initial order like you would with all().
*
*/
export function hash<T>(promises: Thenable<T>[]): Promise<T[]>;
export function hash<T>(promises: any[]): Promise<T[]>;
/**
`RSVP.map` is similar to JavaScript's native `map` method, except that it
waits for all promises to become fulfilled before running the `mapFn` on
each item in given to `promises`. `RSVP.map` returns a promise that will
become fulfilled with the result of running `mapFn` on the values the promises
become fulfilled with.
*/
export function map<T>(promises: Thenable<T>[], mapFn : (item:any)=>any, label? : string): Promise<T[]>;
export function map<T>(promises: any[], mapFn : (item:any)=>any, label? : string): Promise<T[]>;
/**
* `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
* a fail-fast method, it waits until all the promises have returned and
* shows you all the results. This is useful if you want to handle multiple
* promises' failure states together as a set.
*/
export function allSettled<T>(promises: Thenable<T>[]): Promise<PromiseState<T>[]>;
export function allSettled<T>(promises: any[]): Promise<PromiseState<T>[]>;
/**
* `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object
* instead of an array for its `promises` argument.
*
* Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method,
* but like `RSVP.allSettled`, `hashSettled` waits until all the
* constituent promises have returned and then shows you all the results
* with their states and values/reasons. This is useful if you want to
* handle multiple promises' failure states together as a set.
*/
export function hashSettled<T>(promises: Thenable<T>[]): Promise<PromiseState<T>[]>;
export function hashSettled<T>(promises: any[]): Promise<PromiseState<T>[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<R>(promises:Promise<R>[]):Promise<R>;
/**
* `RSVP.denodeify` takes a "node-style" function and returns a function that
* will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
* browser when you'd prefer to use promises over using callbacks. For example,
* `denodeify` transforms the following:
*/
export function denodeify<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
/**
* Favor the Promise Constructor instead (if possible)
*
*/
export function defer<T>(): Deferred<T>;
/**
`RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
*/
export function reject(reason?: any): Promise<any>;
/**
`RSVP.Promise.resolve` returns a promise that will become resolved with the
passed `value`.
*/
export function resolve<T>(object: Thenable<T>): Promise<T>;
export function resolve<T>(object: T): Promise<T>;
/**
* `RSVP.filter` is similar to JavaScript's native `filter` method, except that it
* waits for all promises to become fulfilled before running the `filterFn` on
* each item in given to `promises`. `RSVP.filter` returns a promise that will
* become fulfilled with the result of running `filterFn` on the values the
* promises become fulfilled with.
*/
export function filter<T>(promises: Thenable<T>[], filterFn:(value:any)=>any): Promise<T[]>;
/**
`RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event
loop in order to aid debugging.
Promises A+ specifies that any exceptions that occur with a promise must be
caught by the promises implementation and bubbled to the last handler. For
this reason, it is recommended that you always specify a second rejection
handler function to `then`. However, `RSVP.rethrow` will throw the exception
outside of the promise, so it bubbles up to your console if in the browser,
or domain/cause uncaught exception in Node. `rethrow` will also throw the
error again so the error can be handled by the promise per the spec.
*/
export function rethrow(reason : any):void;
}
declare module "rsvp" {
export = RSVP;
}
+4
View File
@@ -0,0 +1,4 @@
import rsvp = require("rsvp");
var promise = new rsvp.Promise(function(resolve:any, rejector:any){
});
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"rsvp-tests.ts"
]
}
+267
View File
@@ -0,0 +1,267 @@
// Type definitions for wonder-commonlib v0.1.0
// Project: https://github.com/yyc-git/Wonder-CommonLib
// Definitions by: YYC <https://github.com/yyc-git>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module wdCb {
class JudgeUtils {
static isArray(arr: any): boolean;
static isArrayExactly(arr: any): boolean;
static isNumber(num: any): boolean;
static isNumberExactly(num: any): boolean;
static isString(str: any): boolean;
static isStringExactly(str: any): boolean;
static isBoolean(bool: any): boolean;
static isDom(obj: any): boolean;
static isObject(obj: any): boolean;
static isDirectObject(obj: any): boolean;
static isHostMethod(object: any, property: any): boolean;
static isNodeJs(): boolean;
static isFunction(func: any): boolean;
}
}
declare var global: any, window: Window;
declare module wdCb {
var root: any;
}
declare module wdCb {
}
declare module wdCb {
const $BREAK: {
break: boolean;
};
const $REMOVE: any;
}
declare module wdCb {
class Log {
static info: {
INVALID_PARAM: string;
helperFunc: (...args: any[]) => string;
assertion: (...args: any[]) => any;
FUNC_INVALID: (...args: any[]) => any;
FUNC_MUST: (...args: any[]) => any;
FUNC_MUST_BE: (...args: any[]) => any;
FUNC_MUST_NOT_BE: (...args: any[]) => any;
FUNC_SHOULD: (...args: any[]) => any;
FUNC_SHOULD_NOT: (...args: any[]) => any;
FUNC_SUPPORT: (...args: any[]) => any;
FUNC_NOT_SUPPORT: (...args: any[]) => any;
FUNC_MUST_DEFINE: (...args: any[]) => any;
FUNC_MUST_NOT_DEFINE: (...args: any[]) => any;
FUNC_UNKNOW: (...args: any[]) => any;
FUNC_EXPECT: (...args: any[]) => any;
FUNC_UNEXPECT: (...args: any[]) => any;
FUNC_EXIST: (...args: any[]) => any;
FUNC_NOT_EXIST: (...args: any[]) => any;
FUNC_ONLY: (...args: any[]) => any;
FUNC_CAN_NOT: (...args: any[]) => any;
};
static log(...messages: any[]): void;
static assert(cond: any, ...messages: any[]): void;
static error(cond: any, ...message: any[]): any;
static warn(...message: any[]): void;
private static _exec(consoleMethod, args, sliceBegin?);
}
}
declare module wdCb {
class List<T> {
protected children: Array<T>;
getCount(): number;
hasChild(child: any): boolean;
hasChildWithFunc(func: Function): boolean;
getChildren(): T[];
getChild(index: number): T;
addChild(child: T): this;
addChildren(arg: Array<T> | List<T> | any): this;
setChildren(children: Array<T>): this;
unShiftChild(child: T): void;
removeAllChildren(): this;
forEach(func: Function, context?: any): this;
toArray(): T[];
protected copyChildren(): T[];
protected removeChildHelper(arg: any): Array<T>;
private _forEach(arr, func, context?);
private _removeChild(arr, func);
}
}
declare module wdCb {
class Collection<T> extends List<T> {
static create<T>(children?: any[]): Collection<T>;
constructor(children?: Array<T>);
clone(): any;
clone(isDeep: boolean): any;
clone(target: Collection<T>): any;
clone(target: Collection<T>, isDeep: boolean): any;
filter(func: (value: T, index: number) => boolean): Collection<T>;
findOne(func: (value: T, index: number) => boolean): T;
reverse(): Collection<T>;
removeChild(arg: any): Collection<T>;
sort(func: (a: T, b: T) => any, isSortSelf?: boolean): Collection<T>;
map(func: (value: T, index: number) => any): Collection<any>;
removeRepeatItems(): Collection<T>;
hasRepeatItems(): false;
}
}
declare module wdCb {
class Hash<T> {
static create<T>(children?: {}): Hash<T>;
constructor(children?: {
[s: string]: T;
});
private _children;
getChildren(): {
[s: string]: T;
};
getCount(): number;
getKeys(): Collection<string>;
getValues(): Collection<T>;
getChild(key: string): T;
setValue(key: string, value: any): this;
addChild(key: string, value: any): this;
addChildren(arg: {} | Hash<T>): this;
appendChild(key: string, value: any): this;
setChildren(children: {
[s: string]: T;
}): void;
removeChild(arg: any): Collection<T>;
removeAllChildren(): void;
hasChild(key: string): boolean;
hasChildWithFunc(func: Function): boolean;
forEach(func: Function, context?: any): this;
filter(func: Function): Hash<T>;
findOne(func: Function): any[];
map(func: Function): Hash<T>;
toCollection(): Collection<any>;
toArray(): Array<T>;
clone(): any;
clone(isDeep: boolean): any;
clone(target: Hash<T>): any;
clone(target: Hash<T>, isDeep: boolean): any;
}
}
declare module wdCb {
class Queue<T> extends List<T> {
static create<T>(children?: any[]): Queue<T>;
constructor(children?: Array<T>);
readonly front: T;
readonly rear: T;
push(element: T): void;
pop(): T;
clear(): void;
}
}
declare module wdCb {
class Stack<T> extends List<T> {
static create<T>(children?: any[]): Stack<T>;
constructor(children?: Array<T>);
readonly top: T;
push(element: T): void;
pop(): T;
clear(): void;
clone(): any;
clone(isDeep: boolean): any;
clone(target: Stack<T>): any;
clone(target: Stack<T>, isDeep: boolean): any;
filter(func: (value: T, index: number) => boolean): Collection<T>;
findOne(func: (value: T, index: number) => boolean): T;
reverse(): Collection<T>;
removeChild(arg: any): Collection<T>;
sort(func: (a: T, b: T) => any, isSortSelf?: boolean): Collection<T>;
map(func: (value: T, index: number) => any): Collection<any>;
removeRepeatItems(): Collection<T>;
hasRepeatItems(): false;
}
}
declare module wdCb {
class AjaxUtils {
static ajax(conf: any): void;
private static _createAjax(error);
private static _isLocalFile(status);
private static _isSoundFile(dataType);
}
}
declare module wdCb {
class ArrayUtils {
static removeRepeatItems(arr: Array<any>, isEqual?: (a: any, b: any) => boolean): any[];
static contain(arr: Array<any>, ele: any): boolean;
}
}
declare module wdCb {
class ConvertUtils {
static toString(obj: any): string;
private static _convertCodeToString(fn);
}
}
declare module wdCb {
class EventUtils {
static bindEvent(context: any, func: any): (event: any) => any;
static addEvent(dom: any, eventName: any, handler: any): void;
static removeEvent(dom: any, eventName: any, handler: any): void;
}
}
declare module wdCb {
class ExtendUtils {
static extendDeep(parent: any, child?: any, filter?: (val: any, i: any) => boolean): any;
static extend(destination: any, source: any): any;
static copyPublicAttri(source: any): {};
}
}
declare module wdCb {
class PathUtils {
static basename(path: string, ext?: string): string;
static changeExtname(pathStr: string, extname: string): string;
static changeBasename(pathStr: string, basename: string, isSameExt?: boolean): string;
static extname(path: string): string;
static dirname(path: string): string;
private static _splitPath(fileName);
}
}
declare module wdCb {
class FunctionUtils {
static bind(object: any, func: Function): () => any;
}
}
declare module wdCb {
class DomQuery {
static create(eleStr: string): any;
static create(dom: HTMLElement): any;
private _doms;
constructor(eleStr: string);
constructor(dom: HTMLElement);
get(index: any): HTMLElement;
prepend(eleStr: string): any;
prepend(dom: HTMLElement): any;
prependTo(eleStr: string): this;
remove(): this;
css(property: string, value: string): void;
attr(name: string): any;
attr(name: string, value: string): any;
text(str?: string): string;
private _isDomEleStr(eleStr);
private _buildDom(eleStr);
private _buildDom(dom);
private _createElement(eleStr);
}
}
declare module "wonder-commonlib" {
export = wdCb;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"wonder-commonlib-tests.ts"
]
}
@@ -0,0 +1,7 @@
import wdCb = require("wonder-commonlib");
var list = wdCb.Collection.create();
list.addChild(1);
+730
View File
@@ -0,0 +1,730 @@
// Type definitions for wonder-frp v0.1.0
// Project: https://github.com/yyc-git/Wonder-FRP
// Definitions by: YYC <https://github.com/yyc-git>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="wonder-commonlib" />
declare module wdFrp {
class JudgeUtils extends wdCb.JudgeUtils {
static isPromise(obj: any): boolean;
static isEqual(ob1: Entity, ob2: Entity): boolean;
static isIObserver(i: IObserver): () => any;
}
}
declare module wdFrp {
var fromNodeCallback: (func: Function, context?: any) => (...funcArgs: any[]) => AnonymousStream;
var fromStream: (stream: any, finishEventName?: string) => AnonymousStream;
var fromReadableStream: (stream: any) => AnonymousStream;
var fromWritableStream: (stream: any) => AnonymousStream;
var fromTransformStream: (stream: any) => AnonymousStream;
}
declare module wdFrp {
abstract class Entity {
static UID: number;
private _uid;
uid: string;
constructor(uidPre: string);
}
}
declare module wdFrp {
class Main {
static isTest: boolean;
}
}
declare module wdFrp {
function assert(cond: boolean, message?: string): void;
function require(InFunc: any): (target: any, name: any, descriptor: any) => any;
function ensure(OutFunc: any): (target: any, name: any, descriptor: any) => any;
function requireGetter(InFunc: any): (target: any, name: any, descriptor: any) => any;
function requireSetter(InFunc: any): (target: any, name: any, descriptor: any) => any;
function ensureGetter(OutFunc: any): (target: any, name: any, descriptor: any) => any;
function ensureSetter(OutFunc: any): (target: any, name: any, descriptor: any) => any;
function invariant(func: any): (target: any) => void;
}
declare module wdFrp {
interface IDisposable {
dispose(): void;
}
}
declare module wdFrp {
class SingleDisposable extends Entity implements IDisposable {
static create(disposeHandler?: Function): SingleDisposable;
private _disposeHandler;
private _isDisposed;
constructor(disposeHandler: Function);
setDisposeHandler(handler: Function): void;
dispose(): void;
}
}
declare module wdFrp {
class GroupDisposable extends Entity implements IDisposable {
static create(disposable?: IDisposable): GroupDisposable;
private _group;
private _isDisposed;
constructor(disposable?: IDisposable);
add(disposable: IDisposable): this;
remove(disposable: IDisposable): this;
dispose(): void;
}
}
declare module wdFrp {
interface IObserver extends IDisposable {
next(value: any): any;
error(error: any): any;
completed(): any;
}
}
declare module wdFrp {
class InnerSubscription implements IDisposable {
static create(subject: Subject | GeneratorSubject, observer: Observer): InnerSubscription;
private _subject;
private _observer;
constructor(subject: Subject | GeneratorSubject, observer: Observer);
dispose(): void;
}
}
declare module wdFrp {
class InnerSubscriptionGroup implements IDisposable {
static create(): InnerSubscriptionGroup;
private _container;
addChild(child: IDisposable): void;
dispose(): void;
}
}
declare var global: any, window: Window;
declare module wdFrp {
var root: any;
}
declare module wdFrp {
}
declare module wdFrp {
}
declare module wdFrp {
}
declare module wdFrp {
abstract class Stream extends Entity {
scheduler: Scheduler;
subscribeFunc: (observer: IObserver) => Function | void;
constructor(subscribeFunc: any);
abstract subscribe(arg1: Function | Observer | Subject, onError?: Function, onCompleted?: Function): IDisposable;
buildStream(observer: IObserver): IDisposable;
do(onNext?: Function, onError?: Function, onCompleted?: Function): DoStream;
map(selector: Function): MapStream;
flatMap(selector: Function): MergeAllStream;
concatMap(selector: Function): any;
mergeAll(): MergeAllStream;
concatAll(): any;
skipUntil(otherStream: Stream): SkipUntilStream;
takeUntil(otherStream: Stream): TakeUntilStream;
take(count?: number): AnonymousStream;
takeLast(count?: number): AnonymousStream;
takeWhile(predicate: (value: any, index: number, source: Stream) => boolean, thisArg?: this): AnonymousStream;
lastOrDefault(defaultValue?: any): AnonymousStream;
filter(predicate: (value: any) => boolean, thisArg?: this): any;
filterWithState(predicate: (value: any) => boolean, thisArg?: this): any;
concat(streamArr: Array<Stream>): any;
concat(...otherStream: any[]): any;
merge(maxConcurrent: number): any;
merge(streamArr: Array<Stream>): any;
merge(...otherStreams: any[]): any;
repeat(count?: number): RepeatStream;
ignoreElements(): IgnoreElementsStream;
protected handleSubject(subject: any): boolean;
private _isSubject(subject);
private _setSubject(subject);
}
}
declare module wdFrp {
class Scheduler {
static create(...args: any[]): Scheduler;
private _requestLoopId;
requestLoopId: any;
publishRecursive(observer: IObserver, initial: any, action: Function): void;
publishInterval(observer: IObserver, initial: any, interval: number, action: Function): number;
publishIntervalRequest(observer: IObserver, action: Function): void;
publishTimeout(observer: IObserver, time: number, action: Function): number;
}
}
declare module wdFrp {
abstract class Observer extends Entity implements IObserver {
private _isDisposed;
isDisposed: boolean;
protected onUserNext: Function;
protected onUserError: Function;
protected onUserCompleted: Function;
private _isStop;
private _disposable;
constructor(observer: IObserver);
constructor(onNext: Function, onError: Function, onCompleted: Function);
next(value: any): any;
error(error: any): void;
completed(): void;
dispose(): void;
setDisposable(disposable: IDisposable): void;
protected abstract onNext(value: any): any;
protected abstract onError(error: any): any;
protected abstract onCompleted(): any;
}
}
declare module wdFrp {
class Subject implements IObserver {
static create(): Subject;
private _source;
source: Stream;
private _observer;
subscribe(arg1?: Function | Observer, onError?: Function, onCompleted?: Function): IDisposable;
next(value: any): void;
error(error: any): void;
completed(): void;
start(): void;
remove(observer: Observer): void;
dispose(): void;
}
}
declare module wdFrp {
class GeneratorSubject extends Entity implements IObserver {
static create(): GeneratorSubject;
private _isStart;
isStart: boolean;
constructor();
observer: any;
onBeforeNext(value: any): void;
onAfterNext(value: any): void;
onIsCompleted(value: any): boolean;
onBeforeError(error: any): void;
onAfterError(error: any): void;
onBeforeCompleted(): void;
onAfterCompleted(): void;
subscribe(arg1?: Function | Observer, onError?: Function, onCompleted?: Function): IDisposable;
next(value: any): void;
error(error: any): void;
completed(): void;
toStream(): any;
start(): void;
stop(): void;
remove(observer: Observer): void;
dispose(): void;
}
}
declare module wdFrp {
class AnonymousObserver extends Observer {
static create(onNext: Function, onError: Function, onCompleted: Function): AnonymousObserver;
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class AutoDetachObserver extends Observer {
static create(observer: IObserver): any;
static create(onNext: Function, onError: Function, onCompleted: Function): any;
dispose(): void;
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class MapObserver extends Observer {
static create(currentObserver: IObserver, selector: Function): MapObserver;
private _currentObserver;
private _selector;
constructor(currentObserver: IObserver, selector: Function);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class DoObserver extends Observer {
static create(currentObserver: IObserver, prevObserver: IObserver): DoObserver;
private _currentObserver;
private _prevObserver;
constructor(currentObserver: IObserver, prevObserver: IObserver);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class MergeAllObserver extends Observer {
static create(currentObserver: IObserver, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable): MergeAllObserver;
constructor(currentObserver: IObserver, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable);
done: boolean;
currentObserver: IObserver;
private _streamGroup;
private _groupDisposable;
protected onNext(innerSource: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class MergeObserver extends Observer {
static create(currentObserver: IObserver, maxConcurrent: number, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable): MergeObserver;
constructor(currentObserver: IObserver, maxConcurrent: number, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable);
done: boolean;
currentObserver: IObserver;
activeCount: number;
q: Array<Stream>;
private _maxConcurrent;
private _groupDisposable;
private _streamGroup;
handleSubscribe(innerSource: any): void;
protected onNext(innerSource: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
private _isReachMaxConcurrent();
}
}
declare module wdFrp {
class TakeUntilObserver extends Observer {
static create(prevObserver: IObserver): TakeUntilObserver;
private _prevObserver;
constructor(prevObserver: IObserver);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class SkipUntilSourceObserver extends Observer {
static create(prevObserver: IObserver, skipUntilStream: SkipUntilStream): SkipUntilSourceObserver;
private _prevObserver;
private _skipUntilStream;
constructor(prevObserver: IObserver, skipUntilStream: SkipUntilStream);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class SkipUntilOtherObserver extends Observer {
static create(prevObserver: IObserver, skipUntilStream: SkipUntilStream): SkipUntilOtherObserver;
otherDisposable: IDisposable;
private _prevObserver;
private _skipUntilStream;
constructor(prevObserver: IObserver, skipUntilStream: SkipUntilStream);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class ConcatObserver extends Observer {
static create(currentObserver: IObserver, startNextStream: Function): ConcatObserver;
protected currentObserver: any;
private _startNextStream;
constructor(currentObserver: IObserver, startNextStream: Function);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
interface ISubjectObserver {
addChild(observer: Observer): any;
removeChild(observer: Observer): any;
}
}
declare module wdFrp {
class SubjectObserver implements IObserver {
observers: wdCb.Collection<IObserver>;
private _disposable;
isEmpty(): boolean;
next(value: any): void;
error(error: any): void;
completed(): void;
addChild(observer: Observer): void;
removeChild(observer: Observer): void;
dispose(): void;
setDisposable(disposable: IDisposable): void;
}
}
declare module wdFrp {
class IgnoreElementsObserver extends Observer {
static create(currentObserver: IObserver): IgnoreElementsObserver;
private _currentObserver;
constructor(currentObserver: IObserver);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class FilterObserver extends Observer {
static create(prevObserver: IObserver, predicate: (value: any, index?: number, source?: Stream) => boolean, source: Stream): FilterObserver;
constructor(prevObserver: IObserver, predicate: (value: any) => boolean, source: Stream);
protected prevObserver: IObserver;
protected source: Stream;
protected i: number;
protected predicate: (value: any, index?: number, source?: Stream) => boolean;
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class FilterWithStateObserver extends FilterObserver {
static create(prevObserver: IObserver, predicate: (value: any, index?: number, source?: Stream) => boolean, source: Stream): FilterWithStateObserver;
private _isTrigger;
protected onNext(value: any): void;
}
}
declare module wdFrp {
abstract class BaseStream extends Stream {
abstract subscribeCore(observer: IObserver): IDisposable;
subscribe(arg1: Function | Observer | Subject, onError?: any, onCompleted?: any): IDisposable;
buildStream(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class DoStream extends BaseStream {
static create(source: Stream, onNext?: Function, onError?: Function, onCompleted?: Function): DoStream;
private _source;
private _observer;
constructor(source: Stream, onNext: Function, onError: Function, onCompleted: Function);
subscribeCore(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class MapStream extends BaseStream {
static create(source: Stream, selector: Function): MapStream;
private _source;
private _selector;
constructor(source: Stream, selector: Function);
subscribeCore(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class FromArrayStream extends BaseStream {
static create(array: Array<any>, scheduler: Scheduler): FromArrayStream;
private _array;
constructor(array: Array<any>, scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class FromPromiseStream extends BaseStream {
static create(promise: any, scheduler: Scheduler): FromPromiseStream;
private _promise;
constructor(promise: any, scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class FromEventPatternStream extends BaseStream {
static create(addHandler: Function, removeHandler: Function): FromEventPatternStream;
private _addHandler;
private _removeHandler;
constructor(addHandler: Function, removeHandler: Function);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class AnonymousStream extends Stream {
static create(subscribeFunc: Function): AnonymousStream;
constructor(subscribeFunc: Function);
subscribe(subject: Subject): IDisposable;
subscribe(observer: IObserver): IDisposable;
subscribe(onNext: (value: any) => void): IDisposable;
subscribe(onNext: (value: any) => void, onError: (e: any) => void): IDisposable;
subscribe(onNext: (value: any) => void, onError: (e: any) => void, onComplete: () => void): IDisposable;
}
}
declare module wdFrp {
class IntervalStream extends BaseStream {
static create(interval: number, scheduler: Scheduler): IntervalStream;
private _interval;
constructor(interval: number, scheduler: Scheduler);
initWhenCreate(): void;
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class IntervalRequestStream extends BaseStream {
static create(scheduler: Scheduler): IntervalRequestStream;
private _isEnd;
constructor(scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class TimeoutStream extends BaseStream {
static create(time: number, scheduler: Scheduler): TimeoutStream;
private _time;
constructor(time: number, scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class MergeAllStream extends BaseStream {
static create(source: Stream): MergeAllStream;
constructor(source: Stream);
private _source;
private _observer;
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class MergeStream extends BaseStream {
static create(source: Stream, maxConcurrent: number): MergeStream;
constructor(source: Stream, maxConcurrent: number);
private _source;
private _maxConcurrent;
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class TakeUntilStream extends BaseStream {
static create(source: Stream, otherSteam: Stream): TakeUntilStream;
private _source;
private _otherStream;
constructor(source: Stream, otherStream: Stream);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class SkipUntilStream extends BaseStream {
static create(source: Stream, otherSteam: Stream): SkipUntilStream;
isOpen: boolean;
private _source;
private _otherStream;
constructor(source: Stream, otherStream: Stream);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class ConcatStream extends BaseStream {
static create(sources: Array<Stream>): ConcatStream;
private _sources;
constructor(sources: Array<Stream>);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class RepeatStream extends BaseStream {
static create(source: Stream, count: number): RepeatStream;
private _source;
private _count;
constructor(source: Stream, count: number);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class IgnoreElementsStream extends BaseStream {
static create(source: Stream): IgnoreElementsStream;
private _source;
constructor(source: Stream);
subscribeCore(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class DeferStream extends BaseStream {
static create(buildStreamFunc: Function): DeferStream;
private _buildStreamFunc;
constructor(buildStreamFunc: Function);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class FilterStream extends BaseStream {
static create(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): FilterStream;
constructor(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any);
predicate: (value: any, index?: number, source?: Stream) => boolean;
private _source;
subscribeCore(observer: IObserver): IDisposable;
internalFilter(predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): Stream;
protected createObserver(observer: IObserver): Observer;
protected createStreamForInternalFilter(source: Stream, innerPredicate: any, thisArg: any): Stream;
private _innerPredicate(predicate, self);
}
}
declare module wdFrp {
class FilterWithStateStream extends FilterStream {
static create(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): FilterWithStateStream;
protected createObserver(observer: IObserver): FilterWithStateObserver;
protected createStreamForInternalFilter(source: Stream, innerPredicate: any, thisArg: any): Stream;
}
}
declare module wdFrp {
var createStream: (subscribeFunc: any) => AnonymousStream;
var fromArray: (array: any[], scheduler?: Scheduler) => FromArrayStream;
var fromPromise: (promise: any, scheduler?: Scheduler) => FromPromiseStream;
var fromEventPattern: (addHandler: Function, removeHandler: Function) => FromEventPatternStream;
var interval: (interval: any, scheduler?: Scheduler) => IntervalStream;
var intervalRequest: (scheduler?: Scheduler) => IntervalRequestStream;
var timeout: (time: any, scheduler?: Scheduler) => TimeoutStream;
var empty: () => AnonymousStream;
var callFunc: (func: Function, context?: any) => AnonymousStream;
var judge: (condition: Function, thenSource: Function, elseSource: Function) => any;
var defer: (buildStreamFunc: Function) => DeferStream;
var just: (returnValue: any) => AnonymousStream;
}
declare module wdFrp {
enum FilterState {
TRIGGER = 0,
ENTER = 1,
LEAVE = 2,
}
}
declare module wdFrp {
class Record {
static create(time: number, value: any, actionType?: ActionType, comparer?: Function): Record;
private _time;
time: number;
private _value;
value: number;
private _actionType;
actionType: ActionType;
private _comparer;
constructor(time: any, value: any, actionType: ActionType, comparer: Function);
equals(other: any): any;
}
}
declare module wdFrp {
class MockObserver extends Observer {
static create(scheduler: TestScheduler): MockObserver;
private _messages;
messages: [Record];
private _scheduler;
constructor(scheduler: TestScheduler);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
dispose(): void;
clone(): MockObserver;
}
}
declare module wdFrp {
class MockPromise {
static create(scheduler: TestScheduler, messages: [Record]): MockPromise;
private _messages;
private _scheduler;
constructor(scheduler: TestScheduler, messages: [Record]);
then(successCb: Function, errorCb: Function, observer: IObserver): void;
}
}
declare module wdFrp {
class TestScheduler extends Scheduler {
static next(tick: any, value: any): Record;
static error(tick: any, error: any): Record;
static completed(tick: any): Record;
static create(isReset?: boolean): TestScheduler;
constructor(isReset: boolean);
private _clock;
clock: number;
private _isReset;
private _isDisposed;
private _timerMap;
private _streamMap;
private _subscribedTime;
private _disposedTime;
private _observer;
setStreamMap(observer: IObserver, messages: [Record]): void;
remove(observer: Observer): void;
publishRecursive(observer: MockObserver, initial: any, recursiveFunc: Function): void;
publishInterval(observer: IObserver, initial: any, interval: number, action: Function): number;
publishIntervalRequest(observer: IObserver, action: Function): number;
publishTimeout(observer: IObserver, time: number, action: Function): number;
private _setClock();
startWithTime(create: Function, subscribedTime: number, disposedTime: number): MockObserver;
startWithSubscribe(create: any, subscribedTime?: number): MockObserver;
startWithDispose(create: any, disposedTime?: number): MockObserver;
publicAbsolute(time: any, handler: any): void;
start(): void;
createStream(args: any): TestStream;
createObserver(): MockObserver;
createResolvedPromise(time: number, value: any): MockPromise;
createRejectPromise(time: number, error: any): MockPromise;
private _getMinAndMaxTime();
private _exec(time, map);
private _runStream(time);
private _runAt(time, callback);
private _tick(time);
}
}
declare module wdFrp {
enum ActionType {
NEXT = 0,
ERROR = 1,
COMPLETED = 2,
}
}
declare module wdFrp {
class TestStream extends BaseStream {
static create(messages: [Record], scheduler: TestScheduler): TestStream;
scheduler: TestScheduler;
private _messages;
constructor(messages: [Record], scheduler: TestScheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module "wonder-frp" {
export = wdFrp;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"wonder-frp-tests.ts"
]
}
+5
View File
@@ -0,0 +1,5 @@
import wdFrp = require("wonder-frp");
wdFrp.fromArray([1,2,3])
.subscribe(function(){
});