Merge branch 'master' of github.com:borisyankov/DefinitelyTyped

This commit is contained in:
Grégoire Castre
2014-01-20 14:35:56 +01:00
31 changed files with 2432 additions and 179 deletions
+4
View File
@@ -32,12 +32,14 @@ List of Definitions
* [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/))
* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes))
* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib))
* [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib))
* [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted))
* [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago))
* [Arbiter](http://arbiterjs.com/) (by [Arash Shakery](https://github.com/arash16))
* [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov))
* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
* [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm))
* [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds))
* [Bootbox](https://github.com/makeusabrew/bootbox) (by [Vincent Bortone](https://github.com/vbortone/))
* [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov))
* [bootstrap-notify](https://github.com/Nijikokun/bootstrap-notify) (by [Blake Niemyjski](https://github.com/niemyjski))
@@ -64,6 +66,7 @@ List of Definitions
* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/))
* [expect.js](https://github.com/LearnBoost/expect.js) (by [Teppei Sato](https://github.com/teppeis))
* [expectations](https://github.com/spmason/expectations) (by [vvakame](https://github.com/vvakame))
* [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
@@ -149,6 +152,7 @@ List of Definitions
* [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov))
* [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved))
* [jQuery.base64](https://github.com/yatt/jquery.base64) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki))
* [js-git](https://github.com/creationix/js-git) (by [Bart van der Schoor](https://github.com/Bartvds))
* [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz))
* [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk))
* [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/))
@@ -0,0 +1,25 @@
/// <reference path="angular-translate.d.ts" />
var app = angular.module('at', ['pascalprecht.translate']);
app.config(($translateProvider: ng.translate.ITranslateProvider) => {
$translateProvider.translations('en', {
TITLE: 'Hello',
FOO: 'This is a paragraph.',
BUTTON_LANG_EN: 'english',
BUTTON_LANG_DE: 'german'
});
$translateProvider.translations('de', {
TITLE: 'Hallo',
FOO: 'Dies ist ein Paragraph.',
BUTTON_LANG_EN: 'englisch',
BUTTON_LANG_DE: 'deutsch'
});
$translateProvider.preferredLanguage('en');
});
app.controller('Ctrl', ($scope: ng.IScope, $translate: ng.translate.ITranslateService) => {
$scope['changeLanguage'] = function (key: any) {
$translate.uses(key);
};
});
+63
View File
@@ -0,0 +1,63 @@
// Type definitions for Angular Translate (pascalprecht.translate module)
// Project: https://github.com/PascalPrecht/angular-translate
// Definitions by: Michel Salib <michelsalib@hotmail.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ng.translate {
interface ITranslationTable {
[key: string]: string;
}
interface IStorage {
get(name: string): string;
set(name: string, value: string): void;
}
interface ISTaticFilesLoaderOptions {
prefix: string;
suffix: string;
key?: string;
}
interface ITranslateService {
(key: string, ...params: string[]): string;
fallbackLanguage(): string;
preferredLanguage(): string;
proposedLanguage(): string;
refresh(lankKey: string): ng.IPromise<void>;
storage(): IStorage;
storageKey(): string;
uses(): string;
uses(key: string): ng.IPromise<string>;
}
interface ITranslateProvider extends ng.IServiceProvider {
translations(key: string, translationTable: ITranslationTable): ITranslateProvider;
addInterpolation(factory: any): ITranslateProvider;
useMessageFormatInterpolation(): ITranslateProvider;
useInterpolation(factory: string): ITranslateProvider;
preferredLanguage(): string;
preferredLanguage(language: string): ITranslateProvider;
translationNotFoundIndicator(indicator: string): ITranslateProvider;
translationNotFoundIndicatorLeft(): string;
translationNotFoundIndicatorLeft(indicator: string): ITranslateProvider;
translationNotFoundIndicatorRight(): string;
translationNotFoundIndicatorRight(indicator: string): ITranslateProvider;
fallbackLanguage(): string;
fallbackLanguage(language: string): ITranslateProvider;
uses(): string;
uses(key: string): ITranslateProvider;
useUrlLoader(url: string): ITranslateProvider;
useStaticFilesLoader(options: ISTaticFilesLoaderOptions): ITranslateProvider;
useLoader(loaderFactory: string, options: any): ITranslateProvider;
useLocalStorage(): ITranslateProvider;
useCookieStorage(): ITranslateProvider;
useStorage(storageFactory: any): ITranslateProvider;
storagePrefix(): string;
storagePrefix(prefix: string): ITranslateProvider;
useMissingTranslationHandlerLog(): ITranslateProvider;
useMissingTranslationHandler(factory: string): ITranslateProvider;
}
}
+4
View File
@@ -105,6 +105,7 @@ declare module ng {
filter(object: Object): IModule;
provider(name: string, serviceProviderConstructor: Function): IModule;
provider(name: string, inlineAnnotadedConstructor: any[]): IModule;
provider(name: string, providerObject: auto.IProvider): IModule;
provider(object: Object): IModule;
run(initializationFunction: Function): IModule;
run(inlineAnnotadedFunction: any[]): IModule;
@@ -806,6 +807,9 @@ declare module ng {
// AUTO module (angular.js)
///////////////////////////////////////////////////////////////////////////
export module auto {
interface IProvider {
$get: any;
}
///////////////////////////////////////////////////////////////////////
// InjectorService
+327
View File
@@ -0,0 +1,327 @@
/// <reference path="bluebird.d.ts" />
var obj:Object;
var bool:boolean;
var num:number;
var str:string;
var x:any = null;
var f:Function;
var arr:any[];
var exp:RegExp;
var strArr:string[];
var numArr:string[];
var value:any = null;
var reason:any = null;
var Promise:Bluebird.PromiseStatic;
var promise:Bluebird.Promise;
var p:Bluebird.Promise;
var resolver:Bluebird.PromiseResolver;
var inspection:Bluebird.PromiseInspection;
var arrLike:Bluebird.ArrayLike;
// - - - - - - - - - - - - - - - - - - - - - - - -
var promise = new Promise((resolve:(value:any) => void, reject:(reason:any) => void) => {
if(true) {
resolve(123);
}
else {
reject(new Error('nope'));
}
});
// - - - - - - - - - - - - - - - - - - - - - - - -
num = arrLike.length;
// - - - - - - - - - - - - - - - - - - - - - - - -
resolver.resolve(x);
resolver.reject(x);
resolver.progress(x);
resolver.callback = () => {
};
// - - - - - - - - - - - - - - - - - - - - - - - -
bool = inspection.isFulfilled();
bool = inspection.isRejected();
bool = inspection.isPending();
x = inspection.value();
x = inspection.error();
// - - - - - - - - - - - - - - - - - - - - - - - -
p = promise.then((value:any) => {
}, (reason:any) => {
}, (note:any) => {
});
p = promise.then((value:any) => {
}, (reason:any) => {
});
p = promise.then((value:any) => {
});
p = promise.catch((reason:any) => {
});
p = promise.caught((reason:any) => {
});
p = promise.catch((reason:any) => {
return true;
}, (reason:any) => {
});
p = promise.caught((reason:any) => {
return true;
}, (reason:any) => {
});
p = promise.catch(Error, (reason:any) => {
});
p = promise.caught(Error, (reason:any) => {
});
p = promise.error((reason:any) => {
});
p = promise.finally((value:any) => {
});
p = promise.lastly((value:any) => {
});
p = promise.bind(x);
p = promise.done((value:any) => {
}, (reason:any) => {
}, (note:any) => {
});
p = promise.done((value:any) => {
}, (reason:any) => {
});
p = promise.done((value:any) => {
});
p = promise.progressed((note:any) => {
});
p = promise.delay(x);
p = promise.timeout(x);
p = promise.timeout(x, str);
p = promise.nodeify();
p = promise.nodeify(function(err:any) {
});
p = promise.cancellable();
p = promise.cancel();
p = promise.fork((value:any) => {
}, (reason:any) => {
}, (note:any) => {
});
p = promise.fork((value:any) => {
}, (reason:any) => {
});
p = promise.fork((value:any) => {
});
p = promise.uncancellable();
bool = promise.isCancellable();
bool = promise.isFulfilled();
bool = promise.isRejected();
bool = promise.isPending();
bool = promise.isResolved();
inspection = promise.inspect();
p = promise.call(str, 1, 2, 3);
p = promise.get(str);
p = promise.return(value);
p = promise.thenReturn();
p = promise.throw(x);
p = promise.thenThrow();
str = promise.toString();
obj = promise.toJSON();
p = promise.all();
p = promise.props();
p = promise.settle();
p = promise.any();
p = promise.some(x);
p = promise.race();
p = promise.spread((value:any) => {
}, (reason:any) => {
});
p = promise.spread((value:any) => {
});
p = promise.map((item:any, index:number, arrayLength:number) => {
return x;
});
p = promise.reduce((total:number, memo:any, index:number, arrayLength:number) => {
return memo;
});
p = promise.reduce((total:number, memo:any, index:number, arrayLength:number) => {
return memo;
}, x);
p = promise.filter((item:any, index?:number, arrayLength?:number) => {
return true;
});
// - - - - - - - - - - - - - - - - - - - - - - - -
p = new Promise((resolve:(value:any) => any, reject:(reason:any) => any) => {
if(true) {
resolve(value);
}
else {
reject(new Error('xyz'));
}
});
p = Promise.try(() => {});
p = Promise.try(() => {}, arr);
p = Promise.try(() => {}, arr, x);
p = Promise.try(() => {}, arrLike);
p = Promise.try(() => {}, arrLike, x);
p = Promise.attempt(() => {});
p = Promise.attempt(() => {}, arr);
p = Promise.attempt(() => {}, arr, x);
p = Promise.attempt(() => {}, arrLike);
p = Promise.attempt(() => {}, arrLike, x);
f = Promise.method(function() {
});
p = Promise.resolve(value);
p = Promise.reject(reason);
resolver = Promise.defer();
p = Promise.cast(value);
p = Promise.bind(x);
bool = Promise.is(value);
Promise.longStackTraces();
p = Promise.delay(p, x);
p = Promise.delay(value, x);
p = Promise.delay(x);
f = Promise.promisify(f);
f = Promise.promisify(f, x);
obj = Promise.promisify(obj);
obj = Promise.promisifyAll(obj);
f = Promise.coroutine(f);
p = Promise.spawn(f);
obj = Promise.noConflict();
Promise.onPossiblyUnhandledRejection((reason:any) => {
});
p = Promise.all(arr);
p = Promise.props(p);
p = Promise.props(obj);
p = Promise.settle(arr);
p = Promise.any(arr);
p = Promise.race(arr);
p = Promise.some(arr, x);
p = Promise.join(1, 2, 3);
p = Promise.map(arr, (item:any, index:number, arrayLength:number) => {
return x;
});
p = Promise.reduce(arr, (total:number, memo:any, index:number, arrayLength:number) => {
return memo;
});
p = Promise.reduce(arr, (total:number, memo:any, index:number, arrayLength:number) => {
return memo;
}, x);
p = Promise.filter(arr, (item:any, index?:number, arrayLength?:number) => {
return true;
});
+498
View File
@@ -0,0 +1,498 @@
// Type definitions for bluebird 1.0.0
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Bluebird {
interface ArrayLike {
length:number;
}
interface Promise {
/**
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
*/
then(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any, progressHandler?:(note:any) => any):Promise;
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
catch(handler:(reason:any) => any):Promise;
caught(handler:(reason:any) => any):Promise;
/**
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
*
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
//TODO expand this complex overload (weird)
catch(predicate:(reason:any) => boolean, handler:(reason:any) => any):Promise;
caught(predicate:(reason:any) => boolean, handler:(reason:any) => any):Promise;
catch(ErrorClass:Function, handler:(reason:any) => any):Promise;
caught(ErrorClass:Function, handler:(reason:any) => any):Promise;
/**
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
*/
error(rejectedHandler:(reason:any) => any):Promise;
/**
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
*
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
*/
finally(handler:(value:any) => any):Promise;
lastly(handler:(value:any) => any):Promise;
/**
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
*/
bind(thisArg:any):Promise;
/**
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
*/
done(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any, progressHandler?:(note:any) => any):Promise;
/**
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
*/
progressed(handler:(note:any) => any):Promise;
/**
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
delay(ms:number):Promise;
/**
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
*
* You may specify a custom error message with the `message` parameter.
*/
timeout(ms:number, message?:string):Promise;
/**
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
*/
nodeify(callback?:Function):Promise;
/**
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
*/
cancellable():Promise;
/**
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
*
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
*
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
*
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
*/
cancel():Promise;
/**
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
*/
fork(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any, progressHandler?:(note:any) => any):Promise;
/**
* Create an uncancellable promise based on this promise.
*/
uncancellable():Promise;
/**
* See if this promise can be cancelled.
*/
isCancellable():boolean;
/**
* See if this `promise` has been fulfilled.
*/
isFulfilled():boolean;
/**
* See if this `promise` has been rejected.
*/
isRejected():boolean;
/**
* See if this `promise` is still defer.
*/
isPending():boolean;
/**
* See if this `promise` is resolved -> either fulfilled or rejected.
*/
isResolved():boolean;
/**
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
*/
inspect():PromiseInspection;
/**
* This is a convenience method for doing:
*
* <code>
* promise.then(function(obj){
* return obj[propertyName].call(obj, arg...);
* });
* </code>
*/
call(propertyName:string, ...args:any[]):Promise;
/**
* This is a convenience method for doing:
*
* <code>
* promise.then(function(obj){
* return obj[propertyName];
* });
* </code>
*/
get(propertyName:string):Promise;
/**
* Convenience method for:
*
* <code>
* .then(function() {
* return value;
* });
* </code>
*
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
*
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
*/
return(value:any):Promise;
thenReturn():Promise;
/**
* Convenience method for:
*
* <code>
* .then(function() {
* throw reason;
* });
* </code>
* Same limitations apply as with `.return()`.
*
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
*/
throw(reason:any):Promise;
thenThrow():Promise;
/**
* Convert to String.
*/
toString():string;
/**
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
*/
toJSON():Object;
/**
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
all():Promise;
/**
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
props():Promise;
/**
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
settle():Promise;
/**
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
any():Promise;
/**
* Same as calling `Promise.race(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
some(count:number):Promise;
/**
* Same as calling `Promise.some(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
race():Promise;
/**
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
*/
spread(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any):Promise;
/**
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
map(mapper:(item:any, index:number, arrayLength:number) => any):Promise;
/**
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
reduce(reducer:(total:number, current:any, index:number, arrayLength:number) => any, initialValue?:any):Promise;
/**
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
filter(filterer:(item:any, index:number, arrayLength:number) => any):Promise;
}
interface PromiseResolver {
/**
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
*/
resolve(value:any):void;
/**
* Reject the underlying promise with `reason` as the rejection reason.
*/
reject(reason:any):void;
/**
* Progress the underlying promise with `value` as the progression value.
*/
progress(value:any):void;
/**
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
*
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
*/
callback:Function;
}
interface PromiseInspection {
/**
* See if the underlying promise was fulfilled at the creation time of this inspection object.
*/
isFulfilled():boolean;
/**
* See if the underlying promise was rejected at the creation time of this inspection object.
*/
isRejected():boolean;
/**
* See if the underlying promise was defer at the creation time of this inspection object.
*/
isPending():boolean;
/**
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
*
* throws `TypeError`
*/
value():any;
/**
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
*
* throws `TypeError`
*/
error():any;
}
interface PromiseStatic {
/**
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
*/
new(resolver:(resolve:(value:any) => void, reject:(reason:any) => any) => void):Promise;
/**
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
*
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
*
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
*/
try(fn:() => any, args?:any[], ctx?:any):Promise;
try(fn:() => any, args?:ArrayLike, ctx?:any):Promise;
attempt(fn:() => any, args?:any[], ctx?:any):Promise;
attempt(fn:() => any, args?:ArrayLike, ctx?:any):Promise;
/**
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
*/
method(fn:Function):Function;
/**
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
*/
resolve(value:any):Promise;
/**
* Create a promise that is rejected with the given `reason`.
*/
reject(reason:any):Promise;
/**
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?:Promise(#promise-resolution).
*/
defer():PromiseResolver;
/**
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is:Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that:Promise assimilates the state of the thenable.
*/
cast(value:any):Promise;
/**
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
*/
bind(thisArg:any):Promise;
/**
* See if `value` is a trusted Promise.
*/
is(value:any):boolean;
/**
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
*/
longStackTraces():void;
/**
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
*/
delay(value:Promise, ms:number):Promise;
delay(value:any, ms:number):Promise;
delay(ms:number):Promise;
/**
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
*
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
*
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
*/
promisify(nodeFunction:Function, receiver?:any):Function;
/**
* This overload has been **deprecated**. The overload will continue working for now. The recommended method for promisifying multiple methods at once is ``Promise.promisifyAll(Object target)``
*/
promisify(target:Object):Object;
/**
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
*
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
*/
promisifyAll(target:Object):Object;
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
coroutine(generatorFunction:Function):Function;
/**
* Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
spawn(generatorFunction:Function):Promise;
/**
* This is relevant to browser environments with no module loader.
*
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
*/
noConflict():Object;
/**
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
*
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
*/
onPossiblyUnhandledRejection(handler:(reason:any) => any):void;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
*/
all(values:any[]):Promise;
/**
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
*
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
*
* *The original object is not modified.*
*/
props(object:Promise):Promise;
props(object:Object):Promise;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
*
* *original:The array is not modified. The input array sparsity is retained in the resulting array.*
*/
settle(values:any[]):Promise;
/**
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
*/
any(values:any[]):Promise;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
*
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
*/
race(values:any[]):Promise;
/**
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
*
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
*
* *The original array is not modified.*
*/
some(values:any[], count:number):Promise;
/**
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
*/
join(...values:any[]):Promise;
/**
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
*
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
*
* *The original array is not modified.*
*/
map(values:any[], mapper:(item:any, index:number, arrayLength:number) => any):Promise;
/**
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
*
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
*/
reduce(values:any[], reducer:(total:number, current:any, index:number, arrayLength:number) => any, initialValue?:any):Promise;
/**
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
*
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
*
* *The original array is not modified.
*/
filter(values:any[], filterer:(item:any, index?:number, arrayLength?:number) => any):Promise;
}
}
+16 -13
View File
@@ -1,6 +1,6 @@
// Type definitions for EaselJS 0.7.0, TweenJS 0.5.0, SoundJS 0.5.0, PreloadJS 0.4.0
// Type definitions for EaselJS 0.7.1, TweenJS 0.5.1, SoundJS 0.5.2, PreloadJS 0.4.1
// Project: http://www.createjs.com/#!/EaselJS
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>, Chris Smith <https://github.com/evilangelist>, Satoru Kimura <https://github.com/gyohk>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/*
@@ -23,13 +23,13 @@ declare module createjs {
// properties
bubbles: boolean;
cancelable: boolean;
currentTarget: Object;
currentTarget: any; // It is 'Object' type officially, but 'any' is easier to use.
defaultPrevented: boolean;
eventPhase: number;
immediatePropagationStopped: boolean;
propagationStopped: boolean;
removed: boolean;
target: Object;
target: any; // It is 'Object' type officially, but 'any' is easier to use.
timeStamp: number;
type: string;
@@ -38,15 +38,15 @@ declare module createjs {
delta: number;
error: string;
id: string;
item: any;
loaded: number;
item: any;
loaded: number;
name: string;
next: string;
params: any[];
params: any;
paused: boolean;
progress: number;
rawResult: Object;
result: Object;
rawResult: any;
result: any;
runTime: number;
src: string;
time: number;
@@ -78,16 +78,19 @@ declare module createjs {
off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function;
on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function;
on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object;
on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object;
off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
removeAllEventListeners(type?: string): void;
removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void;
removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
toString(): string;
willTrigger(type: string): boolean;
}
export function indexOf(array: any[], searchElement: Object): number;
Vendored
+43 -7
View File
@@ -88,42 +88,78 @@ declare module D3 {
* @param arr Array to search
* @param map Accsessor function
*/
min<T, U>(arr: T[], map?: (v: T) => U): U;
min<T, U>(arr: T[], map: (v: T) => U): U;
/**
* Find the minimum value in an array
*
* @param arr Array to search
*/
min<T>(arr: T[]): T;
/**
* Find the maximum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
max<T, U>(arr: T[], map?: (v: T) => U): U;
max<T, U>(arr: T[], map: (v: T) => U): U;
/**
* Find the maximum value in an array
*
* @param arr Array to search
*/
max<T>(arr: T[]): T;
/**
* Find the minimum and maximum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
extent<T, U>(arr: T[], map?: (v: T) => U): U[];
extent<T, U>(arr: T[], map: (v: T) => U): U[];
/**
* Find the minimum and maximum value in an array
*
* @param arr Array to search
*/
extent<T>(arr: T[]): T[];
/**
* Compute the sum of an array of numbers
*
* @param arr Array to search
* @param map Accsessor function
*/
sum<T>(arr: T[], map?: (v: T) => number): number;
sum<T>(arr: T[], map: (v: T) => number): number;
/**
* Compute the sum of an array of numbers
*
* @param arr Array to search
*/
sum(arr: number[]): number;
/**
* Compute the arithmetic mean of an array of numbers
*
* @param arr Array to search
* @param map Accsessor function
*/
mean<T>(arr: T[], map?: (v: T) => number): number;
mean<T>(arr: T[], map: (v: T) => number): number;
/**
* Compute the arithmetic mean of an array of numbers
*
* @param arr Array to search
*/
mean(arr: number[]): number;
/**
* Compute the median of an array of numbers (the 0.5-quantile).
*
* @param arr Array to search
* @param map Accsessor function
*/
median<T>(arr: T[], map?: (v: T) => number): number;
median<T>(arr: T[], map: (v: T) => number): number;
/**
* Compute the median of an array of numbers (the 0.5-quantile).
*
* @param arr Array to search
*/
median(arr: number[]): number;
/**
* Compute a quantile for a sorted array of numbers.
*
@@ -135,7 +171,7 @@ declare module D3 {
* Locate the insertion point for x in array to maintain sorted order
*
* @param arr Array to search
* @param x Value to serch for insertion point
* @param x Value to search for insertion point
* @param low Minimum value of array subset
* @param hihg Maximum value of array subset
*/
+12
View File
@@ -53,4 +53,16 @@ function test_graphics() {
var myGraphics: createjs.Graphics;
myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(myContext2D);
}
function colorMatrixTest() {
var shape = new createjs.Shape().set({ x: 100, y: 100 });
shape.graphics.beginFill("#ff0000").drawCircle(0, 0, 50);
var matrix = new createjs.ColorMatrix().adjustHue(180).adjustSaturation(100);
shape.filters = [
new createjs.ColorMatrixFilter(matrix)
];
shape.cache(-50, -50, 100, 100);
}
+59 -62
View File
@@ -1,4 +1,4 @@
// Type definitions for EaselJS 0.7.0
// Type definitions for EaselJS 0.7.1
// Project: http://www.createjs.com/#!/EaselJS
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>, Chris Smith <https://github.com/evilangelist>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -55,6 +55,8 @@ declare module createjs {
// methods
clone(): Bitmap;
set(props: Object): Bitmap;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Bitmap;
}
/**
@@ -73,6 +75,9 @@ declare module createjs {
spriteSheet: SpriteSheet;
text: string;
// methods
set(props: Object): BitmapText;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): BitmapText;
}
export class BlurFilter extends Filter {
@@ -120,12 +125,8 @@ declare module createjs {
clone(): ColorFilter;
}
export class ColorMatrix implements Array<number> {
constructor(brightness: number, contrast: number, saturation: number, hue: number);
static DELTA_INDEX: number[];
static IDENTITY_MATRIX: number[];
static LENGTH: number;
export class ColorMatrix {
constructor(brightness?: number, contrast?: number, saturation?: number, hue?: number);
// methods
adjustBrightness(value: number): ColorMatrix;
@@ -135,41 +136,17 @@ declare module createjs {
adjustSaturation(value: number): ColorMatrix;
clone(): ColorMatrix;
concat(...matrix: number[]): ColorMatrix;
copyMatrix(...matrix: ColorMatrix[]): ColorMatrix;
concat(matrix: ColorMatrix): ColorMatrix;
copyMatrix(...matrix: number[]): ColorMatrix;
copyMatrix(matrix: ColorMatrix): ColorMatrix;
reset(): ColorMatrix;
toArray(): number[];
// implements Array interface start
concat<ColorMatrix>(...items: ColorMatrix[]): number[];
join(separator?: string): string;
pop(): number;
push(...items: number[]): number;
reverse(): number[];
shift(): number;
slice(start: number, end?: number): number[];
sort(compareFn?: (a: number, b: number) => number): number[];
splice(start: number): number[];
unshift(...items: number[]): number;
indexOf(searchElement: number, fromIndex?: number): number;
lastIndexOf(searchElement: number, fromIndex?: number): number;
every(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any): boolean;
some(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any): boolean;
forEach(callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any): void;
map<ColorMatrix>(callbackfn: (value: number, index: number, array: number[]) => ColorMatrix, thisArg?: any): ColorMatrix[];
filter(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any): number[];
reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue?: number): number;
reduce<ColorMatrix>(callbackfn: (previousValue: ColorMatrix, currentValue: number, currentIndex: number, array: number[]) => ColorMatrix, initialValue: ColorMatrix): ColorMatrix;
reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue?: number): number;
reduceRight<ColorMatrix>(callbackfn: (previousValue: ColorMatrix, currentValue: number, currentIndex: number, array: number[]) => ColorMatrix, initialValue: ColorMatrix): ColorMatrix;
length: number;
[n: number]: number;
// implements Array interface end
toString(): string;
}
export class ColorMatrixFilter extends Filter {
constructor(matrix: number[]);
constructor(matrix: ColorMatrix);
// methods
clone(): ColorMatrixFilter;
@@ -177,7 +154,7 @@ declare module createjs {
export class Command {
// methods
constructor(f: any, params: any, path: any);
constructor(f: any, params: any, path?: any);
exec(scope: any): void;
}
@@ -187,6 +164,7 @@ declare module createjs {
// properties
children: DisplayObject[];
mouseChildren: boolean;
tickChildren: boolean;
// methods
addChild(...child: DisplayObject[]): DisplayObject;
@@ -203,7 +181,9 @@ declare module createjs {
removeAllChildren(): void;
removeChild(...child: DisplayObject[]): boolean;
removeChildAt(...index: number[]): boolean;
set(props: Object): Container;
setChildIndex(child: DisplayObject, index: number): void;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Container;
sortChildren(sortFunction: (a: DisplayObject, b: DisplayObject) => number): void;
swapChildren(child1: DisplayObject, child2: DisplayObject): void;
swapChildrenAt(index1: number, index2: number): void;
@@ -214,7 +194,7 @@ declare module createjs {
// properties
alpha: number;
cacheCanvas: HTMLCanvasElement; // HTMLCanvasElement or Object
cacheCanvas: any; // HTMLCanvasElement or Object
cacheID: number;
compositeOperation: string;
cursor: string;
@@ -238,6 +218,7 @@ declare module createjs {
*/
snapToPixel: boolean;
static suppressCrossDomainErrors: boolean;
tickEnabled: boolean;
visible: boolean;
x: number;
y: number;
@@ -274,7 +255,8 @@ declare module createjs {
// methods
clone(): DisplayObject; // throw error
set(props: Object): DOMElement;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): DOMElement;
}
@@ -425,6 +407,8 @@ declare module createjs {
constructor(type: string, bubbles: boolean, cancelable: boolean, stageX: number, stageY: number, nativeEvent: NativeMouseEvent, pointerID: number, primary: boolean, rawX: number, rawY: number);
// properties
localX: number;
localY: number;
nativeEvent: NativeMouseEvent;
pointerID: number;
primary: boolean;
@@ -432,7 +416,6 @@ declare module createjs {
rawY: number;
stageX: number;
stageY: number;
target: DisplayObject;
// methods
clone(): MouseEvent;
@@ -442,23 +425,27 @@ declare module createjs {
addEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function;
addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object;
addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object;
on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function;
on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function;
on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object;
on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object;
removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void;
removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
dispatchEvent(eventObj: Object, target?: Object): boolean;
dispatchEvent(eventObj: string, target?: Object): boolean;
dispatchEvent(eventObj: Event, target?: Object): boolean;
hasEventListener(type: string): boolean;
off(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void;
off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
removeAllEventListeners(type?: string): void;
dispatchEvent(eventObj: string, target?: Object): boolean;
dispatchEvent(eventObj: Object, target?: Object): boolean;
dispatchEvent(eventObj: Event, target?: Object): boolean;
hasEventListener(type: string): boolean;
removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void;
removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
toString(): string;
willTrigger(type: string): boolean;
}
@@ -555,6 +542,8 @@ declare module createjs {
// methods
clone(recursive?: boolean): Shape;
set(props: Object): Shape;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Shape;
}
@@ -583,6 +572,8 @@ declare module createjs {
gotoAndStop(frameOrAnimation: string): void;
gotoAndStop(frameOrAnimation: number): void;
play(): void;
set(props: Object): Sprite;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Sprite;
stop(): void;
}
@@ -619,6 +610,8 @@ declare module createjs {
export class SpriteSheetBuilder extends EventDispatcher {
constructor();
// properties
maxHeight: number;
maxWidth: number;
@@ -634,9 +627,9 @@ declare module createjs {
addMovieClip(source: MovieClip, sourceRect?: Rectangle, scale?: number): void;
build(): SpriteSheet;
buildAsync(timeSlice?: number): void;
clone(): DisplayObject; // throw error
clone(): void; // throw error
stopAsync(): void;
toString(): string;
}
@@ -660,7 +653,8 @@ declare module createjs {
// properties
autoClear: boolean;
canvas: HTMLCanvasElement;
canvas: any; // HTMLCanvasElement or Object
handleEvent: Function;
mouseInBounds: boolean;
mouseMoveOutside: boolean;
mouseX: number;
@@ -677,7 +671,6 @@ declare module createjs {
clone(): Stage;
enableDOMEvents(enable?: boolean): void;
enableMouseOver(frequency?: number): void;
handleEvent(evt: Object): void;
toDataURL(backgroundColor: string, mimeType: string): string;
update(...arg: any[]): void;
@@ -703,6 +696,8 @@ declare module createjs {
getMeasuredHeight(): number;
getMeasuredLineHeight(): number;
getMeasuredWidth(): number;
set(props: Object): Text;
setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Text;
}
export class Ticker {
@@ -731,7 +726,6 @@ declare module createjs {
static setFPS(value: number): void;
static setInterval(interval: number): void;
static setPaused(value: boolean): void;
static toString(): string;
// EventDispatcher mixins
static addEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function;
@@ -746,16 +740,19 @@ declare module createjs {
static off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
static off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
static off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
static on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function;
static on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function;
static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object;
static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object;
static off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
static on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
static on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
static removeAllEventListeners(type?: string): void;
static removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void;
static removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
static removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
static toString(): string;
static willTrigger(type: string): boolean;
}
export class TickerEvent {
+162
View File
@@ -0,0 +1,162 @@
/// <reference path="es6-promises.d.ts" />
var promiseString: Promise<string>,
promiseStringArr: Promise<string[]>,
arrayOfPromise: Promise<string>[],
promiseNumber: Promise<number>,
promiseAny: Promise<any>,
thenable: Thenable<string>;
// constructor test
var constructResult = new Promise<string>((resolve, reject) => {
resolve('a string');
});
promiseString = constructResult;
var constructResult1 = new Promise<string>((resolve:(promise: Thenable<string>) => void) => {
resolve(Promise.resolve('a string'));
});
promiseString = constructResult1;
//cast test
var castResult = Promise.cast('a string');
promiseString = castResult;
var castResult1 = Promise.cast(Promise.resolve('a string'));
promiseString = castResult1;
//resolve test
var resolveResult = Promise.resolve('a string');
promiseString = resolveResult;
var resolveResult1 = Promise.resolve(thenable);
promiseString = resolveResult1;
//reject test
var rejectResult = Promise.reject('there is an error');
promiseAny = rejectResult;
//all test
var allResult = Promise.all(arrayOfPromise);
promiseStringArr = allResult;
//race test
var raceResult = Promise.race(arrayOfPromise);
promiseString = raceResult;
//then test
var thenWithPromiseResult = promiseString.then(word => Promise.resolve(word.length));
promiseNumber = thenWithPromiseResult;
var thenWithPromiseResultAndPromiseReject = promiseString.then(word => Promise.resolve(word.length), error => Promise.resolve(10));
promiseNumber = thenWithPromiseResultAndPromiseReject;
var thenWithPromiseResultAndSimpleReject = promiseString.then(word => Promise.resolve(word.length), error => 10);
promiseNumber = thenWithPromiseResultAndSimpleReject;
var thenWithSimpleResult = promiseString.then(word => word.length);
promiseNumber = thenWithSimpleResult;
var thenWithSimpleResultAndPromiseReject = promiseString.then(word => word.length, error => Promise.resolve(10));
promiseNumber = thenWithSimpleResultAndPromiseReject;
var thenWithSimpleResultAndSimpleReject = promiseString.then(word => word.length, error => 10);
promiseNumber = thenWithSimpleResultAndSimpleReject;
var thenWithUndefinedFullFillAndSimpleReject = promiseString.then(undefined, error => 10);
promiseNumber = thenWithUndefinedFullFillAndSimpleReject;
var thenWithUndefinedFullFillAndPromiseReject = promiseString.then(undefined, error => Promise.resolve(10));
promiseNumber = thenWithUndefinedFullFillAndPromiseReject;
var thenWithNoResultAndNoReject = promiseString.then<number>();
promiseNumber = thenWithNoResultAndNoReject;
//catch test
var catchWithSimpleResult = promiseString.catch(error => 10);
promiseNumber = catchWithSimpleResult;
var catchWithPromiseResult = promiseString.catch(error => Promise.resolve(10));
promiseNumber = catchWithPromiseResult;
//examples coming from http://www.html5rocks.com/en/tutorials/es6/promises/
function get(url: string) {
// Return a new promise.
return new Promise<string>(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
if (req.status == 200) {
// Resolve the promise with the response text
resolve(req.response);
}
else {
// Otherwise reject with the status text
// which will hopefully be a meaningful error
reject(Error(req.statusText));
}
};
// Handle network errors
req.onerror = function() {
reject(Error("Network Error"));
};
// Make the request
req.send();
});
}
function getJSON(url: string) {
return get(url).then(JSON.parse);
}
function addHtmlToPage(html: string) {
}
function addTextToPage(text: string) {
}
interface Story {
heading: string;
chapterUrls: string[]
}
getJSON('story.json').then(function(story: Story) {
addHtmlToPage(story.heading);
// Map our array of chapter urls to
// an array of chapter json promises.
// This makes sure they all download parallel.
return story.chapterUrls.map(getJSON)
.reduce(function(sequence, chapterPromise) {
// Use reduce to chain the promises together,
// adding content to the page for each chapter
return sequence.then(function() {
// Wait for everything in the sequence so far,
// then wait for this chapter to arrive.
return chapterPromise;
}).then(function(chapter) {
addHtmlToPage(chapter.html);
});
}, Promise.resolve());
}).then(function() {
addTextToPage("All done");
}).catch(function(err) {
// catch any error that happened along the way
addTextToPage("Argh, broken: " + err.message);
}).then(function() {
(<HTMLElement>document.querySelector('.spinner')).style.display = 'none';
});
@@ -0,0 +1 @@
""
+133
View File
@@ -0,0 +1,133 @@
// Type definitions for es6-promises
// Project: https://github.com/jakearchibald/ES6-Promises
// Definitions by: François de Campredon <https://github.com/fdecampredon/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Thenable<R> {
then<U>(onFulfill: (value: R) => Thenable<U>, onReject: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfill: (value: R) => Thenable<U>, onReject?: (error: any) => U): Thenable<U>;
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Thenable<U>;
}
declare 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);
/**
* 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);
/**
* onFulFill 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 onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill: (value: R) => Thenable<U>, onReject: (error: any) => Thenable<U>): Promise<U>;
/**
* onFulFill 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 onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill: (value: R) => Thenable<U>, onReject?: (error: any) => U): Promise<U>;
/**
* onFulFill 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 onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Thenable<U>): Promise<U>;
/**
* onFulFill 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 onFulFill called when/if "promise" resolves
* @param onReject called when/if "promise" rejects
*/
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onReject called when/if "promise" rejects
*/
catch<U>(onReject?: (error: any) => Thenable<U>): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onReject called when/if "promise" rejects
*/
catch<U>(onReject?: (error: any) => U): Promise<U>;
}
declare module Promise {
/**
* Returns promise (only if promise.constructor == Promise)
*/
function cast<R>(promise: Promise<R>): Promise<R>;
/**
* Make a promise that fulfills to obj.
*/
function cast<R>(object?: R): Promise<R>;
/**
* Make a new promise from the thenable.
* A thenable is promise-like in as far as it has a "then" method.
* This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast.
*/
function resolve<R>(thenable: Thenable<R>): Promise<R>;
/**
* Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation.
*/
function resolve<R>(object?: R): Promise<R>;
/**
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
*/
function reject(error?: any): Promise<any>;
/**
* 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.
*/
function all<R>(promises: Promise<R>[]): Promise<R[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<R>(promises: Promise<R>[]): Promise<R>;
}
+319
View File
@@ -946,6 +946,17 @@ function test_removeData() {
$("span:eq(3)").text("" + $("div").data("test2"));
}
function test_jQuery_removeData() {
var div = $("div")[0];
$("span:eq(0)").text("" + $("div").data("test1"));
jQuery.data(div, "test1", "VALUE-1");
jQuery.data(div, "test2", "VALUE-2");
$("span:eq(1)").text("" + jQuery.data(div, "test1"));
jQuery.removeData(div, "test1");
$("span:eq(2)").text("" + jQuery.data(div, "test1"));
$("span:eq(3)").text("" + jQuery.data(div, "test2"));
}
function test_dblclick() {
$('#target').dblclick(function () {
alert('Handler for .dblclick() called.');
@@ -1095,6 +1106,68 @@ function test_dequeue() {
});
}
function test_queue() {
$("#show").click(function () {
var n = jQuery.queue($("div")[0], "fx");
$("span").text("Queue length is: " + n.length);
});
function runIt() {
$("div")
.show("slow")
.animate({
left: "+=200"
}, 2000)
.slideToggle(1000)
.slideToggle("fast")
.animate({
left: "-=200"
}, 1500)
.hide("slow")
.show(1200)
.slideUp("normal", runIt);
}
runIt();
$(document.body).click(function () {
var divs = $("div")
.show("slow")
.animate({ left: "+=200" }, 2000);
jQuery.queue(divs[0], "fx", function () {
$(this).addClass("newcolor");
jQuery.dequeue(this);
});
divs.animate({ left: "-=200" }, 500);
jQuery.queue(divs[0], "fx", function () {
$(this).removeClass("newcolor");
jQuery.dequeue(this);
});
divs.slideUp();
});
$("#start").click(function () {
var divs = $("div")
.show("slow")
.animate({ left: "+=200" }, 5000);
jQuery.queue(divs[0], "fx", function () {
$(this).addClass("newcolor");
jQuery.dequeue(this);
});
divs.animate({ left: "-=200" }, 1500);
jQuery.queue(divs[0], "fx", function () {
$(this).removeClass("newcolor");
jQuery.dequeue(this);
});
divs.slideUp();
});
$("#stop").click(function () {
jQuery.queue($("div")[0], "fx", []);
$("div").stop();
});
}
function test_detach() {
$("p").click(function () {
$(this).toggleClass("off");
@@ -1669,6 +1742,104 @@ function test_hasData() {
$p.append(jQuery.hasData(p) + " ");
}
function test_jQuery_proxy() {
function test1() {
var me = {
type: "zombie",
test: function (event?) {
// Without proxy, `this` would refer to the event target
// use event.target to reference that element.
var element = event.target;
$(element).css("background-color", "red");
// With proxy, `this` refers to the me object encapsulating
// this function.
$("#log").append("Hello " + this.type + "<br>");
$("#test").off("click", this.test);
}
};
var you = {
type: "person",
test: function (event?) {
$("#log").append(this.type + " ");
}
};
// Execute you.test() in the context of the `you` object
// no matter where it is called
// i.e. the `this` keyword will refer to `you`
var youClick = $.proxy(you.test, you);
// attach click handlers to #test
$("#test")
// this === "zombie"; handler unbound after first click
.on("click", $.proxy(me.test, me))
// this === "person"
.on("click", youClick)
// this === "zombie"
.on("click", $.proxy(you.test, me))
// this === "<button> element"
.on("click", you.test);
}
function test2() {
var obj = {
name: "John",
test: function () {
$("#log").append(this.name);
$("#test").off("click", obj.test);
}
};
$("#test").on("click", jQuery.proxy(obj, "test"));
}
function test3() {
var me = {
// I'm a dog
type: "dog",
// Note that event comes *after* one and two
test: function (one?, two?, event?) {
$("#log")
// `one` maps to `you`, the 1st additional
// argument in the $.proxy function call
.append("<h3>Hello " + one.type + ":</h3>")
// The `this` keyword refers to `me`
// (the 2nd, context, argument of $.proxy)
.append("I am a " + this.type + ", ")
// `two` maps to `they`, the 2nd additional
// argument in the $.proxy function call
.append("and they are " + two.type + ".<br>")
// The event type is "click"
.append("Thanks for " + event.type + "ing.")
// The clicked element is `event.target`,
// and its type is "button"
.append("the " + event.target.type + ".");
}
};
var you = { type: "cat" };
var they = { type: "fish" };
// Set up handler to execute me.test() in the context
// of `me`, with `you` and `they` as additional arguments
var proxy = $.proxy(me.test, me, you, they);
$("#test")
.on("click", proxy);
}
}
function test_height() {
$(window).height();
$(document).height();
@@ -1876,6 +2047,58 @@ function test_scrollTop() {
$("div.demo").scrollTop(300);
}
function test_param() {
function test1() {
var myObject = {
a: {
one: 1,
two: 2,
three: 3
},
b: [1, 2, 3]
};
var recursiveEncoded = $.param(myObject);
var recursiveDecoded = decodeURIComponent($.param(myObject));
alert(recursiveEncoded);
alert(recursiveDecoded);
}
function test2() {
var myObject = {
a: {
one: 1,
two: 2,
three: 3
},
b: [1, 2, 3]
};
var shallowEncoded = $.param(myObject, true);
var shallowDecoded = decodeURIComponent(shallowEncoded);
alert(shallowEncoded);
alert(shallowDecoded);
}
var params = { width: 1680, height: 1050 };
var str = jQuery.param(params);
$("#results").text(str);
// <=1.3.2:
$.param({ a: [2, 3, 4] }); // "a=2&a=3&a=4"
// >=1.4:
$.param({ a: [2, 3, 4] }); // "a[]=2&a[]=3&a[]=4"
// <=1.3.2:
$.param({ a: { b: 1, c: 2 }, d: [3, 4, { e: 5 }] });
// "a=[object+Object]&d=3&d=4&d=[object+Object]"
// >=1.4:
$.param({ a: { b: 1, c: 2 }, d: [3, 4, { e: 5 }] });
// "a[b]=1&a[c]=2&d[]=3&d[]=4&d[2][e]=5"
}
function test_position() {
var p = $("p:first");
var position = p.position();
@@ -2103,6 +2326,102 @@ function test_jquery() {
alert(' b is a jQuery object! ');
}
alert('You are running jQuery version: ' + $.fn.jquery);
$("div.foo");
$("div.foo").click(function () {
$("span", this).addClass("bar");
});
$("div.foo").click(function () {
$(this).slideUp();
});
$.post("url.xml", function (data) {
var $child = $(data).find("child");
});
// Define a plain object
var foo = { foo: "bar", hello: "world" };
// Pass it to the jQuery function
var $foo = $(foo);
// Test accessing property values
var test1 = $foo.prop("foo"); // bar
// Test setting property values
$foo.prop("foo", "foobar");
var test2 = $foo.prop("foo"); // foobar
// Test using .data() as summarized above
$foo.data("keyName", "someValue");
console.log($foo); // will now contain a jQuery{randomNumber} property
// Test binding an event name and triggering
$foo.on("eventName", function () {
console.log("eventName was called");
});
$foo.trigger("eventName"); // Logs "eventName was called"
$foo.triggerHandler("eventName"); // Also logs "eventName was called"
$("div > p").css("border", "1px solid gray");
$("input:radio", document.forms[0]);
$(document.body).css("background", "black");
var myForm: HTMLFormElement;
$(myForm.elements).hide();
$("<p id='test'>My <em>new</em> text</p>").appendTo("body");
$("<a href='http://jquery.com'></a>");
$("<img>");
$("<input>");
var el = $("1<br>2<br>3"); // returns [<br>, "2", <br>]
el = $("1<br>2<br>3 >"); // returns [<br>, "2", <br>, "3 &gt;"]
$("<div></div>", {
"class": "my-div",
on: {
touchstart: function (event) {
// Do something
}
}
}).appendTo("body");
$("<div></div>")
.addClass("my-div")
.on({
touchstart: function (event) {
// Do something
}
})
.appendTo("body");
$("<div><p>Hello</p></div>").appendTo("body")
$("<div/>", {
"class": "test",
text: "Click me!",
click: function () {
$(this).toggleClass("test");
}
})
.appendTo("body");
$(function () {
// Document is ready
});
jQuery(function ($) {
// Your code using failsafe $ alias here...
});
}
function test_keydown() {
+159 -15
View File
@@ -333,7 +333,19 @@ interface JQuerySupport {
}
interface JQueryParam {
/**
* Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
*
* @param obj An array or object to serialize.
*/
(obj: any): string;
/**
* Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
*
* @param obj An array or object to serialize.
* @param traditional A Boolean indicating whether to perform a traditional "shallow" serialization.
*/
(obj: any, traditional: boolean): string;
}
@@ -411,9 +423,9 @@ interface JQueryEasing {
swing(p: number): number;
}
/*
Static members of jQuery (those on $ and jQuery themselves)
*/
/**
* Static members of jQuery (those on $ and jQuery themselves)
*/
interface JQueryStatic {
/**
@@ -510,6 +522,9 @@ interface JQueryStatic {
*/
getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
/**
* Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
*/
param: JQueryParam;
/**
@@ -553,15 +568,71 @@ interface JQueryStatic {
*/
holdReady(hold: boolean): void;
(selector: string, context?: any): JQuery;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
* @param selector A string containing a selector expression
* @param context A DOM Element, Document, or jQuery to use as context
*/
(selector: string, context?: Element): JQuery;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
* @param selector A string containing a selector expression
* @param context A DOM Element, Document, or jQuery to use as context
*/
(selector: string, context?: JQuery): JQuery;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
* @param element A DOM element to wrap in a jQuery object.
*/
(element: Element): JQuery;
(object: {}): JQuery;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
* @param elementArray An array containing a set of DOM elements to wrap in a jQuery object.
*/
(elementArray: Element[]): JQuery;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
* @param object A plain object to wrap in a jQuery object.
*/
(object: {}): JQuery;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
* @param object An existing jQuery object to clone.
*/
(object: JQuery): JQuery;
(func: Function): JQuery;
(array: any[]): JQuery;
/**
* Specify a function to execute when the DOM is fully loaded.
*/
(): JQuery;
/**
* Creates DOM elements on the fly from the provided string of raw HTML.
*
* @param html A string of HTML to create on the fly. Note that this parses HTML, not XML.
* @param ownerDocument A document in which the new elements will be created.
*/
(html: string, ownerDocument?: Document): JQuery;
/**
* Creates DOM elements on the fly from the provided string of raw HTML.
*
* @param html A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
* @param attributes An object of attributes, events, and methods to call on the newly-created element.
*/
(html: string, attributes: Object): JQuery;
/**
* Binds a function to be executed when the DOM has finished loading.
*
* @param callback A function to execute after the DOM is ready.
*/
(callback: Function): JQuery;
/**
* Relinquish jQuery's control of the $ variable.
*
@@ -588,6 +659,9 @@ interface JQueryStatic {
*/
when<T>(...deferreds: any[]): JQueryPromise<T>;
/**
* Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties.
*/
cssHooks: { [key: string]: any; };
cssNumber: any;
@@ -613,24 +687,94 @@ interface JQueryStatic {
*/
data(element: Element): any;
dequeue(element: Element, queueName?: string): any;
/**
* Execute the next function on the queue for the matched element.
*
* @param element A DOM element from which to remove and execute a queued function.
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
*/
dequeue(element: Element, queueName?: string): void;
/**
* Determine whether an element has any jQuery data associated with it.
*
* @param element A DOM element to be checked for data.
*/
hasData(element: Element): boolean;
/**
* Show the queue of functions to be executed on the matched element.
*
* @param element A DOM element to inspect for an attached queue.
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
*/
queue(element: Element, queueName?: string): any[];
queue(element: Element, queueName: string, newQueueOrCallback: any): JQuery;
/**
* Manipulate the queue of functions to be executed on the matched element.
*
* @param element A DOM element where the array of queued functions is attached.
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
* @param newQueue An array of functions to replace the current queue contents.
*/
queue(element: Element, queueName: string, newQueue: Function[]): JQuery;
/**
* Manipulate the queue of functions to be executed on the matched element.
*
* @param element A DOM element on which to add a queued function.
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
* @param callback The new function to add to the queue.
*/
queue(element: Element, queueName: string, callback: Function): JQuery;
/**
* Remove a previously-stored piece of data.
*
* @param element A DOM element from which to remove data.
* @param name A string naming the piece of data to remove.
*/
removeData(element: Element, name?: string): JQuery;
// Deferred
/**
* A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.
*
* @param beforeStart A function that is called just before the constructor returns.
*/
Deferred<T>(beforeStart?: (deferred: JQueryDeferred<T>) => any): JQueryDeferred<T>;
// Effects
fx: { tick: () => void; interval: number; stop: () => void; speeds: { slow: number; fast: number; }; off: boolean; step: any; };
/**
* Effects
*/
fx: {
tick: () => void;
/**
* The rate (in milliseconds) at which animations fire.
*/
interval: number;
stop: () => void;
speeds: { slow: number; fast: number; };
/**
* Globally disable all animations.
*/
off: boolean;
step: any;
};
// Events
proxy(fn: (...args: any[]) => any, context: any, ...args: any[]): any;
proxy(context: any, name: string, ...args: any[]): any;
/**
* Takes a function and returns a new one that will always have a particular context.
*
* @param fnction The function whose context will be changed.
* @param context The object to which the context (this) of the function should be set.
* @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument.
*/
proxy(fnction: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any;
/**
* Takes a function and returns a new one that will always have a particular context.
*
* @param context The object to which the context (this) of the function should be set.
* @param name The name of the function whose context will be changed (should be a property of the context object).
* @param additionalArguments Any number of arguments to be passed to the function named in the name argument.
*/
proxy(context: Object, name: string, ...additionalArguments: any[]): any;
Event: JQueryEventConstructor;
+1 -4
View File
@@ -25,9 +25,6 @@ function test_api() {
var isAbs = $.mobile.path.isAbsoluteUrl("//foo.com/a/file.html");
var dirName = $.mobile.path.get("http://foo.com/a");
$.mobile.silentScroll(100);
$.mobile.showPageLoadingMsg();
$.mobile.hidePageLoadingMsg();
}
function test_pagesDialogs() {
@@ -258,4 +255,4 @@ function test_listview() {
function test_misc() {
$.mobile.initializePage();
}
}
+48 -5
View File
@@ -1,4 +1,4 @@
// Type definitions for jQuery Mobile 1.2
// Type definitions for jQuery Mobile 1.4
// Project: http://jquerymobile.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -143,6 +143,18 @@ interface SliderEvents {
slidestop?: JQueryMobileEvent;
}
interface FlipswitchOptions {
corners?: boolean;
defaults?: boolean;
disabled?: boolean;
enhanced?: boolean;
mini?: boolean;
offText?: string;
onText?: string;
theme?: string;
wrapperClass?: string;
}
interface CheckboxRadioOptions {
mini?: boolean;
theme?: string;
@@ -298,6 +310,30 @@ interface LoaderOptions {
textonly?: boolean;
}
interface JQueryMobilePath {
get(url: string): string;
getDocumentBase(asParsedObject?: boolean): any;
getDocumentUrl(asParsedObject?: boolean): any;
getLocation(): string;
isAbsoluteUrl(url: string): boolean;
isRelativeUrl(url: string): boolean;
makeUrlAbsolute(relUrl: string, absUrl: string): string;
parseLocation(): ParsedPath;
parseUrl(url: string): ParsedPath;
}
interface ParsedPath {
hash: string;
host: string;
hostname: string;
href: string;
pathname: string;
port: string;
protocol: string;
search: string;
}
interface JQueryMobile extends JQueryMobileOptions {
version: string;
@@ -305,8 +341,10 @@ interface JQueryMobile extends JQueryMobileOptions {
changePage(to: any, options?: ChangePageOptions): void;
initializePage(): void;
loadPage(url: any, options?: LoadPageOptions): void;
loading(command: string, options?: LoaderOptions): void;
loading(): JQuery;
loading(command: string, options?: LoaderOptions): JQuery;
pageContainer: any;
base: any;
silentScroll(yPos: number): void;
activePage: JQuery;
@@ -314,14 +352,12 @@ interface JQueryMobile extends JQueryMobileOptions {
options: JQueryMobileOptions;
transitionFallbacks: any;
showPageLoadingMsg(): void;
hidePageLoadingMsg(): void;
loader: any;
page: any;
touchOverflow: any;
showCategory: any;
path: any;
path: JQueryMobilePath;
dialog: any;
popup: any;
@@ -331,6 +367,7 @@ interface JQueryMobile extends JQueryMobileOptions {
collapsibleset: any;
textinput: any;
slider: any;
flipswitch: any;
checkboxradio: any;
selectmenu: any;
listview: any;
@@ -343,6 +380,8 @@ interface JQuerySupport {
interface JQuery {
enhanceWithin(): JQuery;
dialog(): JQuery;
dialog(command: string): JQuery;
dialog(options: DialogOptions): JQuery;
@@ -387,6 +426,10 @@ interface JQuery {
slider(options: SliderOptions): JQuery;
slider(events: SliderEvents): JQuery;
flipswitch(): JQuery;
flipswitch(command: string): JQuery;
flipswitch(options: FlipswitchOptions): JQuery;
checkboxradio(): JQuery;
checkboxradio(command: string): JQuery;
checkboxradio(options: CheckboxRadioOptions): JQuery;
+67
View File
@@ -0,0 +1,67 @@
/// <reference path="js-git.d.ts" />
var obj:Object;
var bool:boolean;
var num:number;
var str:string;
var x:any = null;
var arr:any[];
var exp:RegExp;
var strArr:string[];
var numArr:string[];
var readable:any;
var git_object:JSGit.GitObject;
var commit:JSGit.GitCommit;
var author:JSGit.GitAuthor;
var tree:JSGit.GitTree;
var elem:JSGit.GitTreeElem;
var map:JSGit.StringMap;
var remote:JSGit.Remote;
var db:JSGit.DB;
db.get(str, (err:any, value:any) => {});
db.set(str, x, (err:any) => {});
db.has(str, (err:any, hasKey:boolean) => {});
db.del(str, (err:any) => {});
db.keys(str, (err:any, str:string[]) => {});
db.init((err:any) => {});
db.clear((err:any) => {});
var repo:JSGit.Repo;
repo.load(str, (err:any, git_object:JSGit.GitObject) => {});
repo.save(git_object, (err:any, str:string) => {});
repo.loadAs(str, str, (err:any, body:any) => {});
repo.saveAs(str, x, (err:any, str:string) => {});
repo.remove(str, (err:any) => {});
repo.unpack(x, obj, (err:any) => {});
repo.logWalk(str, (err:any, log_stream:any) => {});
repo.treeWalk(str, (err:any, file_stream:any) => {});
repo.walk(x, x, x, x);
repo.resolveHashish(str, (err:any, str:string) => {});
repo.updateHead(str, (err:any) => {});
repo.getHead((err:any, str:string) => {});
repo.setHead(str, (err:any) => {});
repo.fetch(remote, obj, (err:any) => {});
+188
View File
@@ -0,0 +1,188 @@
// Type definitions for js-git 0.5.2
// Project: https://github.com/creationix/js-git
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module JSGit {
interface GitObject {
type:string;
body:any;
}
interface GitCommit {
tree:string;
author:GitAuthor;
message:string;
}
interface GitAuthor {
name:string;
email:string;
date:Date;
}
interface GitTree {
[i:number]:GitTreeElem;
}
interface GitTreeElem {
mode:number;
name:string;
hash:string;
}
interface StringMap {
[i:string]:string;
}
interface Remote {
hostname:string;
pathname:string;
discover(callback:(err:any, refs:StringMap) => void):void;
fetch(repo:Repo, opts:Object, callback:(err:any) => void):void;
close(callback?:(err:any) => void):void;
}
interface DB {
/**
* Load a ref or object from the database.
* The database should assume that keys that are 40-character long hex strings are sha1 hashes. The value for these will always be binary (Buffer in node, Uint8Array in browser) All other keys are paths like refs/heads/master or HEAD and the value is a string.
*/
get(key:string, callback:(err:any, value:any) => void):void;
/**
* Save a value to the database. Same rules apply about hash keys being binary values and other keys being string values.
*/
set(key:string, value:any, callback:(err:any) => void):void;
/**
* Check if a key is in the database
*/
has(key:string, callback:(err:any, hasKey:boolean) => void):void;
/**
* Remove an object or ref from the database.
*/
del(key:string, callback:(err:any) => void):void;
/**
* Given a path prefix, give all the keys. This is like a readdir if you treat the keys as paths.
* For example, given the keys refs/heads/master, refs/heads/experimental, refs/tags/0.1.3 and the prefix refs/heads/, the output would be master and experimental.
* A null prefix returns all non hash keys.
*/
keys(prefix:string, callback:(err:any, keys:string[]) => void):void;
/**
* Initialize a database. This is where you db implementation can setup stuff.
*/
init(callback:(err:any) => void):void;
/**
* This is for when the user wants to delete or otherwise reclaim your database's resources.
*/
clear(callback:(err:any) => void):void;
}
interface Repo {
/**
* Load a git object from the database. You can pass in either a hash or a symbolic name like HEAD or refs/tags/v3.1.4.
*
* The object will be of the form:
* {
* type: "commit", // Or "tag", "tree", or "blob"
* body: { ... } // Or an array for tree and a binary value for blob.
* }
*/
load(hashish:string, callback:(err:any, git_object:GitObject) => void):void;
/**
* Save an object to the database. This will give you back the hash of the cotent by which you can retrieve the value back.
*/
save(git_object:GitObject, callback:(err:any, hash:string) => void):void;
/**
* This convenience wrapper will call repo.load for you and then check if the type is what you expected. If it is, it will return the body directly. If it's not, it will error.
*
* var commit = yield repo.loadAs("commit", "HEAD");
* var tree = yield repo.loadAs("tree", commit.tree);
*
* I'm using yield syntax because it's simpler, you can use callbacks instead if you prefer.
*/
loadAs(type:string, hash:string, callback:(err:any, body:any) => void):void;
/**
* Another convenience wrapper, this time to save objects as a specefic type. The body must be in the right format.
*
* var blobHash = yield repo.saveAs("blob", binaryData);
* var treeHash = yield repo.saveAs("tree", [
* { mode: 0100644, name: "file.dat", hash: blobHash }
* ]);
* var commitHash = yield repo.saveAs("commit", {
* tree: treeHash,
* author: { name: "Tim Caswell", email: "tim@creationix.com", date: new Date },
* message: "Save the blob"
* });
*/
saveAs(type:string, body:any, callback:(err:any, hash:string) => void):void;
/**
* Remove an object.
*/
remove(hash:string, callback:(err:any) => void):void;
/**
* Import a packfile stream (simple-stream format) into the current database. This is used mostly for clone and fetch operations where the stream comes from a remote repo.
*
* opts is a hash of optional configs.
*
* opts.onProgress(progress) - listen to the git progress channel by passing in a event listener.
* opts.onError(error) - same thing, but for the error channel.
* opts.deline - If this is truthy, the progress and error messages will be rechunked to be whole lines. They usually come jumbled in the internal sidechannel.
*/
unpack(packFileStream:any, opts:Object, callback:(err:any) => void):void;
/**
* This convenience wrapper creates a readable stream of the history sorted by author date.
* If you want full history, pass in HEAD for the hash.
*/
logWalk(hashish:string, callback:(err:any, log_stream:any) => void):void;
/**
* This helper will return a stream of files suitable for traversing a file tree as a linear stream. The hash can be a ref to a commit, a commit hash or a tree hash directly.
*/
treeWalk(hashish:string, callback:(err:any, file_stream:any) => void):void;
/**
* This is the generic helper that logWalk and treeWalk use. See js-git.js source for usage.
*/
walk(seed:any, scan:any, loadKey:any, compare:any):any;
/**
* Resolve a ref, branch, or tag to a real hash.
*/
resolveHashish(hashish:string, callback:(err:any, hash:string) => void):void;
/**
* Update whatever branch HEAD is pointing to so that it points to hash.
* You'll usually want to do this after creating a new commint in the HEAD branch.
*/
updateHead(hash:string, callback:(err:any) => void):void;
/**
* Read the current active branch.
*/
getHead(callback:(err:any, ref_name:string) => void):void;
/**
* Set the current active branch.
*/
setHead(ref:string, callback:(err:any) => void):void;
/**
* Convenience wrapper that fetches from a remote instance and calls repo.unpack with the resulting packfile stream for you.
*/
fetch(remote:Remote, opts:Object, callback:(err:any) => void):void;
}
}
+34
View File
@@ -0,0 +1,34 @@
/// <reference path="../knockout/knockout.d.ts" />
/// <reference path="ko-grid.d.ts" />
module KoGridTests
{
export interface IGridItem {
name: string;
}
export class Tests {
public items: KnockoutObservableArray<IGridItem>;
public selectedItems: KnockoutObservableArray<IGridItem>;
public gridOptionsAlarms: kg.GridOptions<IGridItem>;
constructor() {
this.items = ko.observableArray<IGridItem>();
this.selectedItems = ko.observableArray<IGridItem>();
this.gridOptionsAlarms = this.createDefaultGridOptions(this.items, this.selectedItems);
}
public createDefaultGridOptions<Type>(dataArray: KnockoutObservableArray<Type>, selectedItems: KnockoutObservableArray<Type>): kg.GridOptions<Type> {
var result = {
data: dataArray,
displaySelectionCheckbox: false,
footerVisible: false,
multiSelect: false,
showColumnMenu: false,
plugins: null,
selectedItems: selectedItems
};
return result;
}
}
}
+192
View File
@@ -0,0 +1,192 @@
// Type definitions for ko-grid
// Project: http://knockout-contrib.github.io/KoGrid/
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
// These are very definitely preliminary. Please feel free to improve.
/// <reference path="../knockout/knockout.d.ts" />
declare module kg {
export interface DomUtilityService {
UpdateGridLayout(grid: Grid<any>): void;
BuildStyles(grid: Grid<any>): void;
}
var domUtilityService: DomUtilityService;
export interface Row<EntityType> {
selected: KnockoutObservable<boolean>;
entity: EntityType;
}
export interface RowFactory<EntityType> {
rowCache: Row<EntityType>[];
}
export interface SelectionService<EntityType> {
setSelection(row: Row<EntityType>, selected: boolean): void;
multi: boolean;
lastClickedRow: Row<EntityType>;
}
export interface Grid<EntityType> {
configureColumnWidths(): void;
rowFactory: RowFactory<EntityType>;
config: GridOptions<EntityType>;
$$selectionPhase: boolean;
selectionService: SelectionService<EntityType>;
}
export interface Plugin<EntityType> {
onGridInit(grid: Grid<EntityType>): void;
}
export interface GridOptions<EntityType> {
/** Callback for when you want to validate something after selection. */
afterSelectionChange?(row: Row<EntityType>): void;
/** Callback if you want to inspect something before selection,
return false if you want to cancel the selection. return true otherwise.
If you need to wait for an async call to proceed with selection you can
use rowItem.changeSelection(event) method after returning false initially.
Note: when shift+ Selecting multiple items in the grid this will only get called
once and the rowItem will be an array of items that are queued to be selected. */
beforeSelectionChange?: Function;
/** definitions of columns as an array [], if not defined columns are auto-generated. See github wiki for more details. */
columnDefs?: ColumnDef[];
/** Column width of columns in grid. */
columnWidth?: number;
/** Data being displayed in the grid. Each item in the array is mapped to a row being displayed. */
data?: KnockoutObservableArray<EntityType>;
/** Row selection check boxes appear as the first column. */
displaySelectionCheckbox: boolean;
/** Enable or disable resizing of columns */
enableColumnResize?: boolean;
/** Enables the server-side paging feature */
enablePaging?: boolean;
/** Enable column pinning */
enablePinning?: boolean;
/** Enable drag and drop row reordering. Only works in HTML5 compliant browsers. */
enableRowReordering?: boolean;
/** To be able to have selectable rows in grid. */
enableRowSelection?: boolean;
/** Enables or disables sorting in grid. */
enableSorting?: boolean;
/** filterOptions -
filterText: The text bound to the built-in search box.
useExternalFilter: Bypass internal filtering if you want to roll your own filtering mechanism but want to use builtin search box.
*/
filterOptions?: FilterOptions;
/** Defining the height of the footer in pixels. */
footerRowHeight?: number;
/** Show or hide the footer alltogether the footer is enabled by default */
footerVisible?: boolean;
/** Initial fields to group data by. Array of field names, not displayName. */
groups?: string[];
/** The height of the header row in pixels. */
headerRowHeight?: number;
/** Define a header row template for further customization. See github wiki for more details. */
headerRowTemplate?: any;
/** Enables the use of jquery UI reaggable/droppable plugin. requires jqueryUI to work if enabled.
Useful if you want drag + drop but your users insist on crappy browsers. */
jqueryUIDraggable?: boolean;
/** Enable the use jqueryUIThemes */
jqueryUITheme?: boolean;
/** Prevent unselections when in single selection mode. */
keepLastSelected?: boolean;
/** Maintains the column widths while resizing.
Defaults to true when using *'s or undefined widths. Can be ovverriden by setting to false. */
maintainColumnRatios?: any;
/** Set this to false if you only want one item selected at a time */
multiSelect?: boolean;
/** pagingOptions - */
pagingOptions?: PagingOptions;
/** Array of plugin functions to register in ng-grid */
plugins?: Plugin<EntityType>[];
/** Row height of rows in grid. */
rowHeight?: number;
/** Define a row template to customize output. See github wiki for more details. */
rowTemplate?: any;
/** all of the items selected in the grid. In single select mode there will only be one item in the array. */
selectedItems?: KnockoutObservableArray<any>;
/** Disable row selections by clicking on the row and only when the checkbox is clicked. */
selectWithCheckboxOnly?: boolean;
/** Enables menu to choose which columns to display and group by.
If both showColumnMenu and showFilter are false the menu button will not display.*/
showColumnMenu?: boolean;
/** Enables display of the filterbox in the column menu.
If both showColumnMenu and showFilter are false the menu button will not display.*/
showFilter?: boolean;
/** Show the dropzone for drag and drop grouping */
showGroupPanel?: boolean;
/** Define a sortInfo object to specify a default sorting state.
You can also observe this variable to utilize server-side sorting (see useExternalSorting).
Syntax is sortinfo: { fields: ['fieldName1',' fieldName2'], direction: 'ASC'/'asc' || 'desc'/'DESC'}*/
sortInfo?: any;
/** Set the tab index of the Vieport. */
tabIndex?: number;
/** Prevents the internal sorting from executing.
The sortInfo object will be updated with the sorting information so you can handle sorting (see sortInfo)*/
useExternalSorting?: boolean;
}
export interface ColumnDef {
/** The string name of the property in your data model you want that column to represent. Can also be a property path on your data model. 'foo.bar.myField', 'Name.First', etc.. */
field: string;
/** Sets the pretty display name of the column. default is the field given */
displayName?: string;
/** Sets the width of the column. Can be a fixed width in pixels as an int (42), string px('42px'), percentage string ('42%'), weighted asterisks (width divided by total number of *'s is all column definition widths) See github wiki for more details. */
width?: string;
}
export interface FilterOptions {
filterText?: string;
useExternalFilter?: boolean;
}
export interface PagingOptions {
/** pageSizes: list of available page sizes. */
pageSizes?: number[];
/** pageSize: currently selected page size. */
pageSize?: number;
/** totalServerItems: Total items are on the server. */
totalServerItems?: number;
/** currentPage: the uhm... current page. */
currentPage?: number;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for js 0.3.2
// Type definitions for Lazy.js 0.3.2
// Project: https://github.com/dtao/lazy.js/
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+17 -6
View File
@@ -592,6 +592,9 @@ source.addEventListener('message', <_.LoDashObjectWrapper<Function>>_(function()
'maxWait': 1000
}), false);
var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5);
returnedThrottled(4);
result = <number>_.defer(function() { console.log('deferred'); });
result = <_.LoDashWrapper<number>>_(function() { console.log('deferred'); }).defer();
@@ -608,15 +611,20 @@ var data = {
'curly': { 'name': 'curly', 'age': 60 }
};
var stooge = <Function>_.memoize(function(name: string) { return data[name]; }, _.identity);
var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity);
stooge('curly');
stooge['cache']['curly'].name = 'jerome';
stooge('curly');
var initialize = <Function>_.once(function(){ });
initialize();
var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5);
returnedMemoize(4);
var initialize = _.once(function(){ });
initialize();
initialize();''
var returnedOnce = _.throttle(function (a) { return a * 5; }, 5);
returnedOnce(4);
var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; };
var hi = <Function>_.partial(greetPartial, 'hi');
@@ -638,6 +646,9 @@ jQuery('.interactive').on('click', _.throttle(function() { }, 300000, {
'trailing': false
}));
var returnedThrottled = _.throttle(function (a) { return a*5; }, 5);
returnedThrottled(4);
var helloWrap = function(name: string) { return 'hello ' + name; };
var helloWrap2 = _.wrap(helloWrap, function(func) {
return 'before, ' + func('moe') + ', after';
@@ -950,9 +961,9 @@ class Mage {
}
var mage = new Mage();
result = <number[]>_.times(3, _.partial(_.random, 1, 6));
result = <number[]>_.times(3, function(n: number) { mage.castSpell(n); });
result = <number[]>_.times(3, function(n: number) { this.cast(n); }, mage);
result = _.times(3, <() => number>_.partial(_.random, 1, 6));
result = _.times(3, function(n: number) { mage.castSpell(n); });
result = _.times(3, function(n: number) { this.cast(n); }, mage);
result = <string>_.unescape('Moe, Larry &amp; Curly');
+11 -11
View File
@@ -2580,10 +2580,10 @@ declare module _ {
* @param options.trailing Specify execution on the trailing edge of the timeout.
* @return The new debounced function.
**/
debounce(
func: Function,
debounce<T extends Function>(
func: T,
wait: number,
options?: DebounceSettings): Function;
options?: DebounceSettings): T;
}
interface LoDashObjectWrapper<T> {
@@ -2670,9 +2670,9 @@ declare module _ {
* @param resolver Hash function for storing the result of `fn`.
* @return Returns the new memoizing function.
**/
memoize(
func: Function,
resolver?: (n: any) => string): Function;
memoize<T extends Function>(
func: T,
resolver?: (n: any) => string): T;
}
//_.once
@@ -2684,7 +2684,7 @@ declare module _ {
* @param func Function to only execute once.
* @return The new restricted function.
**/
once(func: Function): Function;
once<T extends Function>(func: T): T;
}
//_.partial
@@ -2733,10 +2733,10 @@ declare module _ {
* @param options.trailing Specify execution on the trailing edge of the timeout.
* @return The new throttled function.
**/
throttle(
func: any,
throttle<T extends Function>(
func: T,
wait: number,
options?: ThrottleSettings): Function;
options?: ThrottleSettings): T;
}
interface ThrottleSettings {
@@ -3764,7 +3764,7 @@ declare module _ {
**/
times<TResult>(
n: number,
callback: Function,
callback: (num: number) => TResult,
context?: any): TResult[];
}
+1
View File
@@ -102,6 +102,7 @@ var getHours: number = moment().hours();
var getDate: number = moment().date();
var getDay: number = moment().day();
var getMonth: number = moment().month();
var getQuater: number = moment().quarter();
var getYear: number = moment().year();
moment().hours(0).minutes(0).seconds(0).milliseconds(0);
+3 -1
View File
@@ -1,7 +1,8 @@
// Type definitions for Moment.js 2.4.0
// Type definitions for Moment.js 2.5.0
// Project: https://github.com/timrwood/moment
// Definitions by: Michael Lakerveld <https://github.com/Lakerfield>
// 2.4.0 Aaron King <https://github.com/kingdango>
// 2.5.0 Hiroki Horiuchi <https://github.com/horiuchi>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
@@ -81,6 +82,7 @@ interface Moment {
year(y: number): Moment;
year(): number;
quarter(): number;
month(M: number): Moment;
month(M: string): Moment;
month(): number;
+1
View File
@@ -257,6 +257,7 @@ interface Contacts {
}
interface Device {
available: boolean;
name: string;
cordova: string;
platform: string;
+17 -13
View File
@@ -1,4 +1,4 @@
// Type definitions for PreloadJS 0.4.0
// Type definitions for PreloadJS 0.4.1
// Project: http://www.createjs.com/#!/PreloadJS
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -22,16 +22,15 @@ declare module createjs {
progress: number;
// methods
buildPath(src: string, basePath?: string, data?: Object): string;
buildPath(src: string, data?: Object): string;
close(): void;
load(): void;
toString(): string;
}
export class LoadQueue extends AbstractLoader {
constructor(useXHR?: boolean, basePath?: string);
constructor(useXHR?: boolean, basePath?: string, crossOrigin?: string);
constructor(useXHR?: boolean, basePath?: string, crossOrigin?: boolean);
// properties
static BINARY: string;
static CSS: string;
@@ -39,8 +38,9 @@ declare module createjs {
static JAVASCRIPT: string;
static JSON: string;
static JSONP: string;
static LOAD_TIMEOUT: number;
static loadTimeout: number;
maintainScriptOrder: boolean;
static MANIFEST: string;
next: LoadQueue;
static SOUND: string;
stopOnError: boolean;
@@ -55,8 +55,9 @@ declare module createjs {
installPlugin(plugin: any): void;
loadFile(file: Object, loadNow?: boolean, basePath?: string): void;
loadFile(file: string, loadNow?: boolean, basePath?: string): void;
loadManifest(manifest: Object[], loadNow?: boolean, basePath?: string): void;
loadManifest(manifest: string[], loadNow?: boolean, basePath?: string): void;
loadManifest(manifest: Object, loadNow?: boolean, basePath?: string): void;
loadManifest(manifest: string, loadNow?: boolean, basePath?: string): void;
loadManifest(manifest: any[], loadNow?: boolean, basePath?: string): void;
remove(idsOrUrls: string): void;
remove(idsOrUrls: any[]): void;
removeAll(): void;
@@ -71,18 +72,21 @@ declare module createjs {
static version: string;
}
export class SamplePlugin {
static fileLoadHandler(event: Object): void;
static getPreloadHandlers(): Object;
static preloadHandler(src: string, type: string, id: string, data: any, basePath: string, queue: LoadQueue): any;
}
export class TagLoader extends AbstractLoader {
constructor (item: Object);
// properties
_isAudio: boolean;
// methods
getResult(): any;
}
export class XHRLoader extends AbstractLoader {
constructor (item: Object);
constructor (item: Object, crossOrigin?: string);
// methods
getAllResponseHeaders(): string;
+1
View File
@@ -36,6 +36,7 @@ interface SignalR {
logging: boolean;
messageId: string;
url: string;
qs: any;
(url: string, queryString?: any, logging?: boolean): SignalR;
hubConnection(url?: string): SignalR;
+20 -37
View File
@@ -1,4 +1,4 @@
// Type definitions for SoundJS 0.5.0
// Type definitions for SoundJS 0.5.2
// Project: http://www.createjs.com/#!/SoundJS
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -19,45 +19,29 @@ declare module createjs {
constructor();
// properties
static BASE_PATH: string;
static buildDate: string;
static capabilities: Object;
flashReady: boolean;
showOutput: boolean;
static swfPath: string;
static version: string;
// methods
create(src: string): SoundInstance;
flashLog(data: string): void;
getVolume(): number;
handleErrorEvent(error: string): void;
handleEvent(method: string): void;
handlePreloadEvent(flashId: string, method: string): void;
handleSoundEvent(flashId: string, method: string): void;
isPreloadStarted(src: string): boolean;
static isSupported(): boolean;
preload(src: string, instance: Object, basePath: string): void;
preload(src: string, instance: Object): void;
register(src: string, instances: number): Object;
registerPreloadInstance(flashId: string, instance: any): void;
registerSoundInstance(flashId: string, instance: any): void;
removeAllSounds (): void;
removeSound(src: string): void;
setMute(value: boolean): boolean;
setVolume(value: number): boolean;
unregisterPreloadInstance(flashId: string): void;
unregisterSoundInstance(flashId: string, instance: any): void;
toString(): string;
}
export class HTMLAudioPlugin {
constructor();
// properties
static AUDIO_ENDED: string;
static AUDIO_ERROR: string;
static AUDIO_READY: string;
static AUDIO_SEEKED: string;
static AUDIO_STALLED: string;
defaultNumChannels: number;
enableIOS: boolean;
static MAX_INSTANCES: number;
@@ -66,18 +50,17 @@ declare module createjs {
create(src: string): SoundInstance;
isPreloadStarted(src: string): boolean;
static isSupported(): boolean;
preload(src: string, instance: Object, basePath: string): void;
preload(src: string, instance: Object): void;
register(src: string, instances: number): Object;
removeAllSounds(): void;
removeSound(src: string): void;
toString(): string;
}
export class Sound {
// properties
static activePlugin: Object;
static alternateExtensions: any[];
static defaultInterruptBehavior: string;
static DELIMITER: string;
static EXTENSION_MAP: Object;
static INTERRUPT_ANY: string;
static INTERRUPT_EARLY: string;
@@ -102,18 +85,18 @@ declare module createjs {
static loadComplete(src: string): boolean;
static play(src: string, interrupt?: any, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance;
static registerManifest(manifest: any[], basePath: string): Object;
static registerPlugin(plugin: Object): boolean;
static registerPlugins(plugins: any[]): boolean;
static registerSound(src: string, id?: string, data?: number, preload?: boolean, basePath?: string): Object;
static registerSound(src: string, id?: string, data?: Object, preload?: boolean, basePath?: string): Object;
static registerSound(src: Object, id?: string, data?: number, preload?: boolean, basePath?: string): Object;
static registerSound(src: Object, id?: string, data?: Object, preload?: boolean, basePath?: string): Object;
static removeAllSounds(): void;
static removeManifest(manifest: any[]): Object;
static removeSound(src: string): boolean;
static removeSound(src: Object): boolean;
static removeManifest(manifest: any[], basePath: string): Object;
static removeSound(src: string, basePath: string): boolean;
static removeSound(src: Object, basePath: string): boolean;
static setMute(value: boolean): boolean;
static setVolume(value: number): void;
static stop(): void;
static toString(): string;
// EventDispatcher mixins
static addEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function;
@@ -128,16 +111,19 @@ declare module createjs {
static off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
static off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
static off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
static on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function;
static on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function;
static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object;
static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object;
static off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
static on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
static on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function;
static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object;
static removeAllEventListeners(type?: string): void;
static removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void;
static removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void;
static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void;
static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void;
static removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee"
static toString(): string;
static willTrigger(type: string): boolean;
}
export class SoundInstance extends EventDispatcher {
@@ -149,6 +135,7 @@ declare module createjs {
panNode: any;
playState: string;
sourceNode: any;
src: string;
uniqueId: any; //HERE string or number
volume: number;
@@ -191,15 +178,11 @@ declare module createjs {
isPreloadStarted(src: string): boolean;
static isSupported(): boolean;
playEmptySound(): void;
preload(src: string, instance: Object): void;
register(src: string, instances: number): Object;
removeAllSounds(src: string): void;
/**
* @deprecated
*/
removeFromPreload(src: string): void;
removeSound(src: string): void;
setMute(value: boolean): boolean;
setVolume(value: number): boolean;
toString(): string;
}
}
+5 -4
View File
@@ -1,4 +1,4 @@
// Type definitions for TweenJS 0.5.0
// Type definitions for TweenJS 0.5.1
// Project: http://www.createjs.com/#!/TweenJS
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>, Chris Smith <https://github.com/evilangelist>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -82,7 +82,7 @@ declare module createjs {
static priority: any;
//methods
static init(tween: Tween, prop: string, value: any): any;
static init(tween: Tween, prop: string, value: any): any;
static step(tween: Tween, prop: string, startValue: any, injectProps: Object, endValue: any): void;
static install(): void;
static tween(tween: Tween, prop: string, value: any, startValues: Object, endValues: Object, ratio: number, wait: boolean, end: boolean): any;
@@ -100,8 +100,8 @@ declare module createjs {
// methods
addLabel(label: string, position: number): void;
addTween(...tween: Tween[]): void;
getCurrentLabel(): string;
getLabels(): Object[];
getCurrentLabel(): string;
getLabels(): Object[];
gotoAndPlay(positionOrLabel: string): void;
gotoAndPlay(positionOrLabel: number): void;
gotoAndStop(positionOrLabel: string): void;
@@ -148,6 +148,7 @@ declare module createjs {
setPaused(value: boolean): Tween;
setPosition(value: number, actionsMode: number): boolean;
static tick(delta: number, paused: boolean): void;
tick(delta: number, paused: boolean): void;
tick(delta: number): void;
to(props: Object, duration?: number, ease?: (t: number) => number): Tween;
wait(duration: number, passive?: boolean): Tween;